Fix "git-log --parents" breakage post v1.3.0
Post 1.3.0 "git log" forgets to list parent commits on the first line when --parents is given. git-cvsserver relied on it. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
May 3, 2006 at 07:59 UTC
c8c893c62b0d9997e7dfe7bd5f636ddbf29ef619
1 file changed
+16
-2
log-tree.c
+16
-2
@@ -3,6 +3,15 @@
3
#include "commit.h"
4
#include "log-tree.h"
5
6
+static void show_parents(struct commit *commit, int abbrev)
7
+{
8
+ struct commit_list *p;
9
+ for (p = commit->parents; p ; p = p->next) {
10
+ struct commit *parent = p->item;
11
+ printf(" %s", diff_unique_abbrev(parent->object.sha1, abbrev));
12
+ }
13
+}
14
+
15
void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
16
{
17
static char this_header[16384];
@@ -14,7 +23,10 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
23
24
opt->loginfo = NULL;
25
if (!opt->verbose_header) {
17
- puts(sha1_to_hex(commit->object.sha1));
26
+ fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
27
+ if (opt->parents)
28
+ show_parents(commit, abbrev_commit);
29
+ putchar('\n');
30
return;
31
}
32
@@ -40,7 +52,9 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
52
printf("%s%s",
53
opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
54
diff_unique_abbrev(commit->object.sha1, abbrev_commit));
43
- if (parent)
55
+ if (opt->parents)
56
+ show_parents(commit, abbrev_commit);
57
+ if (parent)
58
printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit));
59
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
60