@matheusbsbs / matheus-bagliano / commits / 78fff6ebba
Fork 0

Fixes for option parsing

Make sure "git show" always show the header, regardless of whether there is a diff or not. Also, make sure "always_show_header" actually works, since generate_header only tested it in one out of three return paths. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Apr 16, 2006 at 15:17 UTC 78fff6ebbafe2d23464a2b059104954bfe8732c7
2 files changed +15 -4
git.c
+1
@@ -373,6 +373,7 @@ static int cmd_show(int argc, const char **argv, char **envp)
373 rev.diffopt.recursive = 1;
374 rev.combine_merges = 1;
375 rev.dense_combined_merges = 1;
376 + rev.always_show_header = 1;
377 rev.ignore_merges = 0;
378 rev.no_walk = 1;
379 return cmd_log_wc(argc, argv, envp, &rev);
log-tree.c
+14 -4
@@ -43,7 +43,7 @@ static int diff_root_tree(struct rev_info *opt,
43 return retval;
44 }
45
46 -static const char *generate_header(struct rev_info *opt,
46 +static const char *get_header(struct rev_info *opt,
47 const unsigned char *commit_sha1,
48 const unsigned char *parent_sha1,
49 const struct commit *commit)
@@ -75,11 +75,21 @@ static const char *generate_header(struct rev_info *opt,
75 offset += pretty_print_commit(opt->commit_format, commit, len,
76 this_header + offset,
77 sizeof(this_header) - offset, abbrev);
78 + return this_header;
79 +}
80 +
81 +static const char *generate_header(struct rev_info *opt,
82 + const unsigned char *commit_sha1,
83 + const unsigned char *parent_sha1,
84 + const struct commit *commit)
85 +{
86 + const char *header = get_header(opt, commit_sha1, parent_sha1, commit);
87 +
88 if (opt->always_show_header) {
79 - puts(this_header);
80 - return NULL;
89 + puts(header);
90 + header = NULL;
91 }
82 - return this_header;
92 + return header;
93 }
94
95 static int do_diff_combined(struct rev_info *opt, struct commit *commit)