Skip to content

Commit

Permalink
reflog: fix overriding of command line options
Browse files Browse the repository at this point in the history
Currently, "git reflog" overrides some command line options such as
"--format".

Fix this by using the new 2-phase version of cmd_log_init().

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Apr 1, 2011
1 parent 21d2616 commit 4b56cf5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,11 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
rev.verbose_header = 1;
memset(&opt, 0, sizeof(opt));
opt.def = "HEAD";
cmd_log_init(argc, argv, prefix, &rev, &opt);

/*
* This means that we override whatever commit format the user gave
* on the cmd line. Sad, but cmd_log_init() currently doesn't
* allow us to set a different default.
*/
cmd_log_init_defaults(&rev);
rev.commit_format = CMIT_FMT_ONELINE;
rev.use_terminator = 1;
rev.always_show_header = 1;
cmd_log_init_finish(argc, argv, prefix, &rev, &opt);

return cmd_log_walk(&rev);
}
Expand Down
2 changes: 1 addition & 1 deletion t/t1411-reflog-show.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Author: A U Thor <author@example.com>
one
EOF
test_expect_failure 'override reflog default format' '
test_expect_success 'override reflog default format' '
git reflog --format=short -1 >actual &&
test_cmp expect actual
'
Expand Down

0 comments on commit 4b56cf5

Please sign in to comment.