Skip to content

Commit 78fff6e

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
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>
1 parent cb8f64b commit 78fff6e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ static int cmd_show(int argc, const char **argv, char **envp)
373373
rev.diffopt.recursive = 1;
374374
rev.combine_merges = 1;
375375
rev.dense_combined_merges = 1;
376+
rev.always_show_header = 1;
376377
rev.ignore_merges = 0;
377378
rev.no_walk = 1;
378379
return cmd_log_wc(argc, argv, envp, &rev);

log-tree.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int diff_root_tree(struct rev_info *opt,
4343
return retval;
4444
}
4545

46-
static const char *generate_header(struct rev_info *opt,
46+
static const char *get_header(struct rev_info *opt,
4747
const unsigned char *commit_sha1,
4848
const unsigned char *parent_sha1,
4949
const struct commit *commit)
@@ -75,11 +75,21 @@ static const char *generate_header(struct rev_info *opt,
7575
offset += pretty_print_commit(opt->commit_format, commit, len,
7676
this_header + offset,
7777
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+
7888
if (opt->always_show_header) {
79-
puts(this_header);
80-
return NULL;
89+
puts(header);
90+
header = NULL;
8191
}
82-
return this_header;
92+
return header;
8393
}
8494

8595
static int do_diff_combined(struct rev_info *opt, struct commit *commit)

0 commit comments

Comments
 (0)