Introduce 'git-format-patch --suffix=.patch'
[git/git.git] / builtin-log.c
CommitLineData
70827b15
LT
1/*
2 * Builtin "git log" and related commands (show, whatchanged)
3 *
4 * (C) Copyright 2006 Linus Torvalds
5 * 2006 Junio Hamano
6 */
7#include "cache.h"
8#include "commit.h"
9#include "diff.h"
10#include "revision.h"
11#include "log-tree.h"
91efcf60 12#include "builtin.h"
5d7eeee2 13#include "tag.h"
70827b15 14
0f03ca94
PB
15static int default_show_root = 1;
16
e686eb98
JS
17/* this is in builtin-diff.c */
18void add_head(struct rev_info *revs);
19
a633fca0 20static void cmd_log_init(int argc, const char **argv, const char *prefix,
70827b15
LT
21 struct rev_info *rev)
22{
52883fbd
JH
23 int i;
24
70827b15
LT
25 rev->abbrev = DEFAULT_ABBREV;
26 rev->commit_format = CMIT_FMT_DEFAULT;
27 rev->verbose_header = 1;
0f03ca94 28 rev->show_root_diff = default_show_root;
70827b15 29 argc = setup_revisions(argc, argv, rev, "HEAD");
9dafea26
TH
30 if (rev->diffopt.pickaxe || rev->diffopt.filter)
31 rev->always_show_header = 0;
52883fbd
JH
32 for (i = 1; i < argc; i++) {
33 const char *arg = argv[i];
34 if (!strncmp(arg, "--encoding=", 11)) {
35 arg += 11;
52883fbd 36 if (strcmp(arg, "none"))
d2c11a38 37 git_log_output_encoding = strdup(arg);
52883fbd 38 else
d2c11a38 39 git_log_output_encoding = "";
52883fbd
JH
40 }
41 else
42 die("unrecognized argument: %s", arg);
43 }
9dafea26
TH
44}
45
46static int cmd_log_walk(struct rev_info *rev)
47{
48 struct commit *commit;
70827b15
LT
49
50 prepare_revision_walk(rev);
70827b15
LT
51 while ((commit = get_revision(rev)) != NULL) {
52 log_tree_commit(rev, commit);
53 free(commit->buffer);
54 commit->buffer = NULL;
cb115748
LT
55 free_commit_list(commit->parents);
56 commit->parents = NULL;
70827b15
LT
57 }
58 return 0;
59}
60
0f03ca94
PB
61static int git_log_config(const char *var, const char *value)
62{
63 if (!strcmp(var, "log.showroot")) {
64 default_show_root = git_config_bool(var, value);
65 return 0;
66 }
67 return git_diff_ui_config(var, value);
68}
69
a633fca0 70int cmd_whatchanged(int argc, const char **argv, const char *prefix)
70827b15
LT
71{
72 struct rev_info rev;
73
0f03ca94 74 git_config(git_log_config);
db6296a5 75 init_revisions(&rev, prefix);
70827b15
LT
76 rev.diff = 1;
77 rev.diffopt.recursive = 1;
9202434c 78 rev.simplify_history = 0;
a633fca0 79 cmd_log_init(argc, argv, prefix, &rev);
9dafea26
TH
80 if (!rev.diffopt.output_format)
81 rev.diffopt.output_format = DIFF_FORMAT_RAW;
82 return cmd_log_walk(&rev);
70827b15
LT
83}
84
5d7eeee2
JS
85static int show_object(const unsigned char *sha1, int suppress_header)
86{
87 unsigned long size;
88 char type[20];
89 char *buf = read_sha1_file(sha1, type, &size);
90 int offset = 0;
91
92 if (!buf)
93 return error("Could not read object %s", sha1_to_hex(sha1));
94
95 if (suppress_header)
96 while (offset < size && buf[offset++] != '\n') {
97 int new_offset = offset;
98 while (new_offset < size && buf[new_offset++] != '\n')
99 ; /* do nothing */
100 offset = new_offset;
101 }
102
103 if (offset < size)
104 fwrite(buf + offset, size - offset, 1, stdout);
105 free(buf);
106 return 0;
107}
108
109static int show_tree_object(const unsigned char *sha1,
110 const char *base, int baselen,
111 const char *pathname, unsigned mode, int stage)
112{
113 printf("%s%s\n", pathname, S_ISDIR(mode) ? "/" : "");
114 return 0;
115}
116
a633fca0 117int cmd_show(int argc, const char **argv, const char *prefix)
70827b15
LT
118{
119 struct rev_info rev;
5d7eeee2
JS
120 struct object_array_entry *objects;
121 int i, count, ret = 0;
70827b15 122
0f03ca94 123 git_config(git_log_config);
db6296a5 124 init_revisions(&rev, prefix);
70827b15
LT
125 rev.diff = 1;
126 rev.diffopt.recursive = 1;
127 rev.combine_merges = 1;
128 rev.dense_combined_merges = 1;
129 rev.always_show_header = 1;
130 rev.ignore_merges = 0;
131 rev.no_walk = 1;
a633fca0 132 cmd_log_init(argc, argv, prefix, &rev);
5d7eeee2
JS
133
134 count = rev.pending.nr;
135 objects = rev.pending.objects;
136 for (i = 0; i < count && !ret; i++) {
137 struct object *o = objects[i].item;
138 const char *name = objects[i].name;
139 switch (o->type) {
140 case OBJ_BLOB:
141 ret = show_object(o->sha1, 0);
142 break;
143 case OBJ_TAG: {
144 struct tag *t = (struct tag *)o;
145
146 printf("%stag %s%s\n\n",
147 diff_get_color(rev.diffopt.color_diff,
148 DIFF_COMMIT),
149 t->tag,
150 diff_get_color(rev.diffopt.color_diff,
151 DIFF_RESET));
152 ret = show_object(o->sha1, 1);
153 objects[i].item = (struct object *)t->tagged;
154 i--;
155 break;
156 }
157 case OBJ_TREE:
158 printf("%stree %s%s\n\n",
159 diff_get_color(rev.diffopt.color_diff,
160 DIFF_COMMIT),
161 name,
162 diff_get_color(rev.diffopt.color_diff,
163 DIFF_RESET));
164 read_tree_recursive((struct tree *)o, "", 0, 0, NULL,
165 show_tree_object);
166 break;
167 case OBJ_COMMIT:
168 rev.pending.nr = rev.pending.alloc = 0;
169 rev.pending.objects = NULL;
170 add_object_array(o, name, &rev.pending);
171 ret = cmd_log_walk(&rev);
172 break;
173 default:
174 ret = error("Unknown type: %d", o->type);
175 }
176 }
177 free(objects);
178 return ret;
70827b15
LT
179}
180
a633fca0 181int cmd_log(int argc, const char **argv, const char *prefix)
70827b15
LT
182{
183 struct rev_info rev;
184
0f03ca94 185 git_config(git_log_config);
db6296a5 186 init_revisions(&rev, prefix);
70827b15 187 rev.always_show_header = 1;
a633fca0 188 cmd_log_init(argc, argv, prefix, &rev);
9dafea26 189 return cmd_log_walk(&rev);
70827b15 190}
91efcf60 191
0377db77
JS
192static int istitlechar(char c)
193{
194 return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
195 (c >= '0' && c <= '9') || c == '.' || c == '_';
196}
197
20ff0680
JS
198static char *extra_headers = NULL;
199static int extra_headers_size = 0;
03eeaeae 200static const char *fmt_patch_suffix = ".txt";
20ff0680
JS
201
202static int git_format_config(const char *var, const char *value)
203{
204 if (!strcmp(var, "format.headers")) {
205 int len = strlen(value);
206 extra_headers_size += len + 1;
83572c1a 207 extra_headers = xrealloc(extra_headers, extra_headers_size);
20ff0680
JS
208 extra_headers[extra_headers_size - len - 1] = 0;
209 strcat(extra_headers, value);
210 return 0;
211 }
03eeaeae
JH
212 if (!strcmp(var, "format.suffix")) {
213 if (!value)
214 die("format.suffix without value");
215 fmt_patch_suffix = xstrdup(value);
216 return 0;
217 }
a159ca0c 218 if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
f3aafa4d
RA
219 return 0;
220 }
0f03ca94 221 return git_log_config(var, value);
20ff0680
JS
222}
223
224
81f3a188 225static FILE *realstdout = NULL;
efd02016 226static const char *output_directory = NULL;
81f3a188 227
8ac80a57 228static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
0377db77
JS
229{
230 char filename[1024];
231 char *sol;
2448482b 232 int len = 0;
03eeaeae 233 int suffix_len = strlen(fmt_patch_suffix) + 10; /* ., NUL and slop */
0377db77 234
2448482b 235 if (output_directory) {
03eeaeae 236 strlcpy(filename, output_directory, 1000);
2448482b
JS
237 len = strlen(filename);
238 if (filename[len - 1] != '/')
239 filename[len++] = '/';
240 }
0377db77 241
2448482b 242 sprintf(filename + len, "%04d", nr);
0377db77
JS
243 len = strlen(filename);
244
245 sol = strstr(commit->buffer, "\n\n");
246 if (sol) {
247 int j, space = 1;
248
249 sol += 2;
250 /* strip [PATCH] or [PATCH blabla] */
8ac80a57 251 if (!keep_subject && !strncmp(sol, "[PATCH", 6)) {
0377db77
JS
252 char *eos = strchr(sol + 6, ']');
253 if (eos) {
254 while (isspace(*eos))
255 eos++;
256 sol = eos;
257 }
258 }
259
03eeaeae
JH
260 for (j = 0;
261 len < sizeof(filename) - suffix_len &&
262 sol[j] && sol[j] != '\n';
263 j++) {
0377db77
JS
264 if (istitlechar(sol[j])) {
265 if (space) {
266 filename[len++] = '-';
267 space = 0;
268 }
269 filename[len++] = sol[j];
270 if (sol[j] == '.')
271 while (sol[j + 1] == '.')
272 j++;
273 } else
274 space = 1;
275 }
276 while (filename[len - 1] == '.' || filename[len - 1] == '-')
277 len--;
278 }
03eeaeae 279 strcpy(filename + len, fmt_patch_suffix);
81f3a188 280 fprintf(realstdout, "%s\n", filename);
0377db77
JS
281 freopen(filename, "w", stdout);
282}
283
9c6efa36
JS
284static int get_patch_id(struct commit *commit, struct diff_options *options,
285 unsigned char *sha1)
286{
2b60356d
RS
287 if (commit->parents)
288 diff_tree_sha1(commit->parents->item->object.sha1,
289 commit->object.sha1, "", options);
290 else
291 diff_root_tree_sha1(commit->object.sha1, "", options);
9c6efa36
JS
292 diffcore_std(options);
293 return diff_flush_patch_id(options, sha1);
294}
295
a633fca0 296static void get_patch_ids(struct rev_info *rev, struct diff_options *options, const char *prefix)
9c6efa36
JS
297{
298 struct rev_info check_rev;
299 struct commit *commit;
300 struct object *o1, *o2;
301 unsigned flags1, flags2;
302 unsigned char sha1[20];
303
304 if (rev->pending.nr != 2)
305 die("Need exactly one range.");
306
307 o1 = rev->pending.objects[0].item;
308 flags1 = o1->flags;
309 o2 = rev->pending.objects[1].item;
310 flags2 = o2->flags;
311
312 if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
313 die("Not a range.");
314
315 diff_setup(options);
316 options->recursive = 1;
317 if (diff_setup_done(options) < 0)
318 die("diff_setup_done failed");
319
320 /* given a range a..b get all patch ids for b..a */
db6296a5 321 init_revisions(&check_rev, prefix);
9c6efa36
JS
322 o1->flags ^= UNINTERESTING;
323 o2->flags ^= UNINTERESTING;
324 add_pending_object(&check_rev, o1, "o1");
325 add_pending_object(&check_rev, o2, "o2");
326 prepare_revision_walk(&check_rev);
327
328 while ((commit = get_revision(&check_rev)) != NULL) {
329 /* ignore merges */
330 if (commit->parents && commit->parents->next)
331 continue;
332
333 if (!get_patch_id(commit, options, sha1))
334 created_object(sha1, xcalloc(1, sizeof(struct object)));
335 }
336
337 /* reset for next revision walk */
81db0941
JS
338 clear_commit_marks((struct commit *)o1,
339 SEEN | UNINTERESTING | SHOWN | ADDED);
340 clear_commit_marks((struct commit *)o2,
341 SEEN | UNINTERESTING | SHOWN | ADDED);
9c6efa36
JS
342 o1->flags = flags1;
343 o2->flags = flags2;
344}
345
d1566f78
JT
346static void gen_message_id(char *dest, unsigned int length, char *base)
347{
348 const char *committer = git_committer_info(1);
349 const char *email_start = strrchr(committer, '<');
350 const char *email_end = strrchr(committer, '>');
351 if(!email_start || !email_end || email_start > email_end - 1)
352 die("Could not extract email from committer identity.");
76af0734
JH
353 snprintf(dest, length, "%s.%lu.git.%.*s", base,
354 (unsigned long) time(NULL),
355 (int)(email_end - email_start - 1), email_start + 1);
d1566f78
JT
356}
357
a633fca0 358int cmd_format_patch(int argc, const char **argv, const char *prefix)
91efcf60
JH
359{
360 struct commit *commit;
361 struct commit **list = NULL;
362 struct rev_info rev;
2448482b 363 int nr = 0, total, i, j;
0377db77 364 int use_stdout = 0;
596524b3 365 int numbered = 0;
fa0f02df 366 int start_number = -1;
8ac80a57 367 int keep_subject = 0;
9c6efa36 368 int ignore_if_in_upstream = 0;
cc35de84 369 int thread = 0;
76af0734 370 const char *in_reply_to = NULL;
9c6efa36 371 struct diff_options patch_id_opts;
cf2251b6 372 char *add_signoff = NULL;
d1566f78
JT
373 char message_id[1024];
374 char ref_message_id[1024];
91efcf60 375
07efc6a6 376 setup_ident();
97beb812 377 git_config(git_format_config);
db6296a5 378 init_revisions(&rev, prefix);
91efcf60
JH
379 rev.commit_format = CMIT_FMT_EMAIL;
380 rev.verbose_header = 1;
381 rev.diff = 1;
91efcf60
JH
382 rev.combine_merges = 0;
383 rev.ignore_merges = 1;
27e1b127
JH
384 rev.diffopt.msg_sep = "";
385 rev.diffopt.recursive = 1;
91efcf60 386
20ff0680
JS
387 rev.extra_headers = extra_headers;
388
2448482b
JS
389 /*
390 * Parse the arguments before setup_revisions(), or something
391 * like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
392 * possibly a valid SHA1.
393 */
394 for (i = 1, j = 1; i < argc; i++) {
395 if (!strcmp(argv[i], "--stdout"))
0377db77 396 use_stdout = 1;
596524b3
JS
397 else if (!strcmp(argv[i], "-n") ||
398 !strcmp(argv[i], "--numbered"))
399 numbered = 1;
fa0f02df
JS
400 else if (!strncmp(argv[i], "--start-number=", 15))
401 start_number = strtol(argv[i] + 15, NULL, 10);
402 else if (!strcmp(argv[i], "--start-number")) {
403 i++;
404 if (i == argc)
405 die("Need a number for --start-number");
406 start_number = strtol(argv[i], NULL, 10);
cf2251b6
JH
407 }
408 else if (!strcmp(argv[i], "-k") ||
8ac80a57
JS
409 !strcmp(argv[i], "--keep-subject")) {
410 keep_subject = 1;
411 rev.total = -1;
cf2251b6 412 }
efd02016
JH
413 else if (!strcmp(argv[i], "--output-directory") ||
414 !strcmp(argv[i], "-o")) {
2448482b 415 i++;
efd02016
JH
416 if (argc <= i)
417 die("Which directory?");
418 if (output_directory)
419 die("Two output directories?");
420 output_directory = argv[i];
698ce6f8 421 }
cf2251b6
JH
422 else if (!strcmp(argv[i], "--signoff") ||
423 !strcmp(argv[i], "-s")) {
6c4cca1c
EB
424 const char *committer;
425 const char *endpos;
6c4cca1c
EB
426 committer = git_committer_info(1);
427 endpos = strchr(committer, '>');
cf2251b6
JH
428 if (!endpos)
429 die("bogos committer info %s\n", committer);
430 add_signoff = xmalloc(endpos - committer + 2);
431 memcpy(add_signoff, committer, endpos - committer + 1);
432 add_signoff[endpos - committer + 1] = 0;
433 }
698ce6f8
JS
434 else if (!strcmp(argv[i], "--attach"))
435 rev.mime_boundary = git_version_string;
436 else if (!strncmp(argv[i], "--attach=", 9))
437 rev.mime_boundary = argv[i] + 9;
9c6efa36
JS
438 else if (!strcmp(argv[i], "--ignore-if-in-upstream"))
439 ignore_if_in_upstream = 1;
cc35de84
JT
440 else if (!strcmp(argv[i], "--thread"))
441 thread = 1;
da56645d
JT
442 else if (!strncmp(argv[i], "--in-reply-to=", 14))
443 in_reply_to = argv[i] + 14;
444 else if (!strcmp(argv[i], "--in-reply-to")) {
445 i++;
446 if (i == argc)
447 die("Need a Message-Id for --in-reply-to");
448 in_reply_to = argv[i];
449 }
03eeaeae
JH
450 else if (!strncmp(argv[i], "--suffix=", 9))
451 fmt_patch_suffix = argv[i] + 9;
698ce6f8 452 else
2448482b 453 argv[j++] = argv[i];
0377db77 454 }
2448482b
JS
455 argc = j;
456
add5c8a5 457 if (start_number < 0)
fa0f02df 458 start_number = 1;
63b398a4 459 if (numbered && keep_subject)
8ac80a57
JS
460 die ("-n and -k are mutually exclusive.");
461
2448482b
JS
462 argc = setup_revisions(argc, argv, &rev, "HEAD");
463 if (argc > 1)
464 die ("unrecognized argument: %s", argv[1]);
0377db77 465
c9b5ef99
TH
466 if (!rev.diffopt.output_format)
467 rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
468
77e565d8
ML
469 if (!output_directory)
470 output_directory = prefix;
471
efd02016
JH
472 if (output_directory) {
473 if (use_stdout)
474 die("standard output, or directory, which one?");
475 if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
476 die("Could not create directory %s",
477 output_directory);
478 }
479
1f1e895f
LT
480 if (rev.pending.nr == 1) {
481 rev.pending.objects[0].item->flags |= UNINTERESTING;
e686eb98
JS
482 add_head(&rev);
483 }
484
9c6efa36 485 if (ignore_if_in_upstream)
a633fca0 486 get_patch_ids(&rev, &patch_id_opts, prefix);
9c6efa36 487
81f3a188
JS
488 if (!use_stdout)
489 realstdout = fdopen(dup(1), "w");
490
91efcf60
JH
491 prepare_revision_walk(&rev);
492 while ((commit = get_revision(&rev)) != NULL) {
9c6efa36
JS
493 unsigned char sha1[20];
494
0377db77
JS
495 /* ignore merges */
496 if (commit->parents && commit->parents->next)
497 continue;
9c6efa36
JS
498
499 if (ignore_if_in_upstream &&
500 !get_patch_id(commit, &patch_id_opts, sha1) &&
501 lookup_object(sha1))
502 continue;
503
91efcf60 504 nr++;
83572c1a 505 list = xrealloc(list, nr * sizeof(list[0]));
91efcf60
JH
506 list[nr - 1] = commit;
507 }
0377db77 508 total = nr;
596524b3 509 if (numbered)
fa0f02df 510 rev.total = total + start_number - 1;
cf2251b6 511 rev.add_signoff = add_signoff;
da56645d 512 rev.ref_message_id = in_reply_to;
91efcf60
JH
513 while (0 <= --nr) {
514 int shown;
515 commit = list[nr];
add5c8a5 516 rev.nr = total - nr + (start_number - 1);
d1566f78 517 /* Make the second and subsequent mails replies to the first */
cc35de84
JT
518 if (thread) {
519 if (nr == (total - 2)) {
520 strncpy(ref_message_id, message_id,
521 sizeof(ref_message_id));
522 ref_message_id[sizeof(ref_message_id)-1]='\0';
523 rev.ref_message_id = ref_message_id;
524 }
525 gen_message_id(message_id, sizeof(message_id),
526 sha1_to_hex(commit->object.sha1));
527 rev.message_id = message_id;
d1566f78 528 }
0377db77 529 if (!use_stdout)
8ac80a57 530 reopen_stdout(commit, rev.nr, keep_subject);
91efcf60
JH
531 shown = log_tree_commit(&rev, commit);
532 free(commit->buffer);
533 commit->buffer = NULL;
add5c8a5
JH
534
535 /* We put one extra blank line between formatted
536 * patches and this flag is used by log-tree code
537 * to see if it needs to emit a LF before showing
538 * the log; when using one file per patch, we do
539 * not want the extra blank line.
540 */
541 if (!use_stdout)
542 rev.shown_one = 0;
698ce6f8
JS
543 if (shown) {
544 if (rev.mime_boundary)
545 printf("\n--%s%s--\n\n\n",
546 mime_boundary_leader,
547 rev.mime_boundary);
548 else
549 printf("-- \n%s\n\n", git_version_string);
550 }
0377db77
JS
551 if (!use_stdout)
552 fclose(stdout);
91efcf60
JH
553 }
554 free(list);
555 return 0;
556}
557
e827633a
RS
558static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
559{
560 unsigned char sha1[20];
561 if (get_sha1(arg, sha1) == 0) {
562 struct commit *commit = lookup_commit_reference(sha1);
563 if (commit) {
564 commit->object.flags |= flags;
565 add_pending_object(revs, &commit->object, arg);
566 return 0;
567 }
568 }
569 return -1;
570}
571
572static const char cherry_usage[] =
573"git-cherry [-v] <upstream> [<head>] [<limit>]";
574int cmd_cherry(int argc, const char **argv, const char *prefix)
575{
576 struct rev_info revs;
577 struct diff_options patch_id_opts;
578 struct commit *commit;
579 struct commit_list *list = NULL;
580 const char *upstream;
581 const char *head = "HEAD";
582 const char *limit = NULL;
583 int verbose = 0;
584
585 if (argc > 1 && !strcmp(argv[1], "-v")) {
586 verbose = 1;
587 argc--;
588 argv++;
589 }
590
591 switch (argc) {
592 case 4:
593 limit = argv[3];
594 /* FALLTHROUGH */
595 case 3:
596 head = argv[2];
597 /* FALLTHROUGH */
598 case 2:
599 upstream = argv[1];
600 break;
601 default:
602 usage(cherry_usage);
603 }
604
605 init_revisions(&revs, prefix);
606 revs.diff = 1;
607 revs.combine_merges = 0;
608 revs.ignore_merges = 1;
609 revs.diffopt.recursive = 1;
610
611 if (add_pending_commit(head, &revs, 0))
612 die("Unknown commit %s", head);
613 if (add_pending_commit(upstream, &revs, UNINTERESTING))
614 die("Unknown commit %s", upstream);
615
616 /* Don't say anything if head and upstream are the same. */
617 if (revs.pending.nr == 2) {
618 struct object_array_entry *o = revs.pending.objects;
619 if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
620 return 0;
621 }
622
623 get_patch_ids(&revs, &patch_id_opts, prefix);
624
625 if (limit && add_pending_commit(limit, &revs, UNINTERESTING))
626 die("Unknown commit %s", limit);
627
628 /* reverse the list of commits */
629 prepare_revision_walk(&revs);
630 while ((commit = get_revision(&revs)) != NULL) {
631 /* ignore merges */
632 if (commit->parents && commit->parents->next)
633 continue;
634
635 commit_list_insert(commit, &list);
636 }
637
638 while (list) {
639 unsigned char sha1[20];
640 char sign = '+';
641
642 commit = list->item;
643 if (!get_patch_id(commit, &patch_id_opts, sha1) &&
644 lookup_object(sha1))
645 sign = '-';
646
647 if (verbose) {
648 static char buf[16384];
649 pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
650 buf, sizeof(buf), 0, NULL, NULL, 0);
651 printf("%c %s %s\n", sign,
652 sha1_to_hex(commit->object.sha1), buf);
653 }
654 else {
655 printf("%c %s\n", sign,
656 sha1_to_hex(commit->object.sha1));
657 }
658
659 list = list->next;
660 }
661
662 return 0;
663}