From: Sebastian Schuberth Date: Wed, 22 Jul 2015 11:56:09 GMT Subject: [PATCH v2] diff-tree: do not show the sha1 of the given head with --quiet Message-ID: <0000014eb59ef0ad-3d1a00df-9c6b-4414-8f64-6fb959c996a9-000000@eu-west-1.amazonses.com> In-Reply-To: <692dbd9ee45e10a17587970eaa2a1c4e@www.dscho.org> "--quiet" is documented to "Disable all output of the program". Yet calling diff-tree with a single commit like $ git diff-tree --quiet c925fe2 was logging c925fe23684455735c3bb1903803643a24a58d8f to the console despite "--quiet" being given. This is inconsistent with both the docs and the behavior if more than a single commit is passed to diff-tree. Moreover, the output of that single line seems to be documented nowhere except in a comment for a test. Fix this inconsistency by making diff-tree really output nothing if "--quiet" is given and fix the test accordingly. Signed-off-by: Sebastian Schuberth --- log-tree.c | 3 ++- t/t4035-diff-quiet.sh | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/log-tree.c b/log-tree.c index 01beb11..3c98234 100644 --- a/log-tree.c +++ b/log-tree.c @@ -741,7 +741,8 @@ int log_tree_diff_flush(struct rev_info *opt) } if (opt->loginfo && !opt->no_commit_id) { - show_log(opt); + if (!DIFF_OPT_TST(&opt->diffopt, QUICK)) + show_log(opt); if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) && opt->verbose_header && opt->commit_format != CMIT_FMT_ONELINE && diff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh index 461f4bb..9a8225f 100755 --- a/t/t4035-diff-quiet.sh +++ b/t/t4035-diff-quiet.sh @@ -40,11 +40,10 @@ test_expect_success 'git diff-tree HEAD^ HEAD -- b' ' test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt && test_line_count = 0 cnt ' -# this diff outputs one line: sha1 of the given head test_expect_success 'echo HEAD | git diff-tree --stdin' ' echo $(git rev-parse HEAD) | test_expect_code 1 git diff-tree --quiet --stdin >cnt && - test_line_count = 1 cnt + test_line_count = 0 cnt ' test_expect_success 'git diff-tree HEAD HEAD' ' test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt && --- https://github.com/git/git/pull/163