git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] diff-tree: do not show the sha1 of the given head with --quiet

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Jul 22, 2015, 11:56 UTC
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 <sschuberth@gmail.com>
---
 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
Previous: Johannes SchindelinNext: Junio C Hamano
Message 3 of 14 in “diff-tree: do not show the sha1 of the given head with --quiet”
  1. diff-tree: do not show the sha1 of the given head with --quietSebastian Schuberth, Jul 22, 2015
  2. Johannes SchindelinJul 22, 2015
  3. diff-tree: do not show the sha1 of the given head with --quietSebastian Schuberth, Jul 22, 2015
  4. Junio C HamanoJul 22, 2015
  5. Sebastian SchuberthJul 23, 2015
  6. Junio C HamanoJul 23, 2015
  7. Junio C HamanoJul 23, 2015
  8. Sebastian SchuberthJul 23, 2015
  9. Jeff KingJul 23, 2015
  10. Junio C HamanoJul 23, 2015
  11. Sebastian SchuberthJul 23, 2015
  12. Junio C HamanoJul 23, 2015
  13. Sebastian SchuberthJul 23, 2015
  14. Jeff KingJul 24, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.