Skip to content

Commit

Permalink
Fixes for option parsing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Apr 16, 2006
1 parent cb8f64b commit 78fff6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ static int cmd_show(int argc, const char **argv, char **envp)
rev.diffopt.recursive = 1;
rev.combine_merges = 1;
rev.dense_combined_merges = 1;
rev.always_show_header = 1;
rev.ignore_merges = 0;
rev.no_walk = 1;
return cmd_log_wc(argc, argv, envp, &rev);
Expand Down
18 changes: 14 additions & 4 deletions log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int diff_root_tree(struct rev_info *opt,
return retval;
}

static const char *generate_header(struct rev_info *opt,
static const char *get_header(struct rev_info *opt,
const unsigned char *commit_sha1,
const unsigned char *parent_sha1,
const struct commit *commit)
Expand Down Expand Up @@ -75,11 +75,21 @@ static const char *generate_header(struct rev_info *opt,
offset += pretty_print_commit(opt->commit_format, commit, len,
this_header + offset,
sizeof(this_header) - offset, abbrev);
return this_header;
}

static const char *generate_header(struct rev_info *opt,
const unsigned char *commit_sha1,
const unsigned char *parent_sha1,
const struct commit *commit)
{
const char *header = get_header(opt, commit_sha1, parent_sha1, commit);

if (opt->always_show_header) {
puts(this_header);
return NULL;
puts(header);
header = NULL;
}
return this_header;
return header;
}

static int do_diff_combined(struct rev_info *opt, struct commit *commit)
Expand Down

0 comments on commit 78fff6e

Please sign in to comment.