Thread (7 messages) flat view 7 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH 3/4] reflog: fix overriding of command line options

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:50:57
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 builtin/log.c          |    9 ++-------
 t/t1411-reflog-show.sh |    2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index f585209..916019c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -495,16 +495,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);
 }
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index 88dc6a7..caa687b 100755
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
@@ -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
 '
-- 
1.7.4.2.668.gba03a4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help