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

[PATCH 2/2] prune.c: only print informational message in show_only or verbose mode

From
Brandon Casey <drafnel@gmail.com>
Date
Aug 7, 2012, 05:01 UTC
Message-ID
<1344315709-15897-2-git-send-email-drafnel@gmail.com>
In-Reply-To
<1344315709-15897-1-git-send-email-drafnel@gmail.com>

This informational message can cause a problem if 'git prune' is spawned from an auto-gc during receive-pack. In this case, the informational message will be sent back over the wire to the git client and the client will try to interpret it as part of the pack protocol and will produce an error.

So let's refrain from producing this message unless show_only or verbose is enabled.

This fixes the test in t5400.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 builtin/prune.c      | 3 ++-
 t/t5400-send-pack.sh | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/prune.c b/builtin/prune.c
index b99b635..6cb9944 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -25,7 +25,8 @@ static int prune_tmp_object(const char *path, const char *filename)
 		return error("Could not stat '%s'", fullpath);
 	if (st.st_mtime > expire)
 		return 0;
-	printf("Removing stale temporary file %s\n", fullpath);
+	if (show_only || verbose)
+		printf("Removing stale temporary file %s\n", fullpath);
 	if (!show_only)
 		unlink_or_warn(fullpath);
 	return 0;
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 04a8791..250c720 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -145,7 +145,7 @@ test_expect_success 'push --all excludes remote-tracking hierarchy' '
 	)
 '
 
-test_expect_failure 'receive-pack runs auto-gc in remote repo' '
+test_expect_success 'receive-pack runs auto-gc in remote repo' '
 	rm -rf parent child &&
 	git init parent &&
 	(
-- 
1.7.12.rc1.17.g9a7365c
Previous: Brandon CaseyNext: Junio C Hamano
Message 5 of 15 in “Did we break receive-pack recently?”
  1. Junio C HamanoAug 5, 2012
  2. Brandon CaseyAug 6, 2012
  3. Brandon CaseyAug 6, 2012
  4. 1/2 t/t5400: demonstrate breakage caused by informational message from pruneBrandon Casey, Aug 7, 2012
  5. 2/2 prune.c: only print informational message in show_only or verbose modeBrandon Casey, Aug 7, 2012
  6. Junio C HamanoAug 7, 2012
  7. Junio C HamanoAug 7, 2012
  8. Brandon CaseyAug 7, 2012
  9. Jeff KingAug 7, 2012
  10. Brandon CaseyAug 7, 2012
  11. Junio C HamanoAug 7, 2012
  12. Junio C HamanoAug 7, 2012
  13. Jeff KingAug 7, 2012
  14. Brandon CaseyAug 7, 2012
  15. Jeff KingAug 7, 2012

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.