diff options
| author | Junio C Hamano <gitster@pobox.com> | 2012-08-27 11:55:00 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2012-08-27 11:55:00 -0700 |
| commit | 2df9988470d8f1ad82a642eb6d5b2ddde1512bc0 (patch) | |
| tree | 5a10c4258125a42765dc02b5bef1fc2a877409d1 | |
| parent | e6daf0ac2209eb5c69f28c008715ad1a3b79c057 (diff) | |
| parent | 4b7f2fa4c6c2c4675ab00474d419fa356afdfa71 (diff) | |
| download | git-2df9988470d8f1ad82a642eb6d5b2ddde1512bc0.tar.xz | |
Merge branch 'bc/receive-pack-stdout-protection'
When "git push" triggered the automatic gc on the receiving end, a
message from "git prune" that said it was removing cruft leaked to
the standard output, breaking the communication protocol.
* bc/receive-pack-stdout-protection:
receive-pack: do not leak output from auto-gc to standard output
t/t5400: demonstrate breakage caused by informational message from prune
| -rw-r--r-- | builtin/receive-pack.c | 3 | ||||
| -rwxr-xr-x | t/t5400-send-pack.sh | 35 |
2 files changed, 37 insertions, 1 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 0afb8b2896..3f05d971ec 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -977,7 +977,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) const char *argv_gc_auto[] = { "gc", "--auto", "--quiet", NULL, }; - run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); + int opt = RUN_GIT_CMD | RUN_COMMAND_STDOUT_TO_STDERR; + run_command_v_opt(argv_gc_auto, opt); } if (auto_update_server_info) update_server_info(0); diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index 0eace37a03..250c720c14 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -145,6 +145,41 @@ test_expect_success 'push --all excludes remote-tracking hierarchy' ' ) ' +test_expect_success 'receive-pack runs auto-gc in remote repo' ' + rm -rf parent child && + git init parent && + ( + # Setup a repo with 2 packs + cd parent && + echo "Some text" >file.txt && + git add . && + git commit -m "Initial commit" && + git repack -adl && + echo "Some more text" >>file.txt && + git commit -a -m "Second commit" && + git repack + ) && + cp -a parent child && + ( + # Set the child to auto-pack if more than one pack exists + cd child && + git config gc.autopacklimit 1 && + git branch test_auto_gc && + # And create a file that follows the temporary object naming + # convention for the auto-gc to remove + : >.git/objects/tmp_test_object && + test-chmtime =-1209601 .git/objects/tmp_test_object + ) && + ( + cd parent && + echo "Even more text" >>file.txt && + git commit -a -m "Third commit" && + git send-pack ../child HEAD:refs/heads/test_auto_gc >output 2>&1 && + grep "Auto packing the repository for optimum performance." output + ) && + test ! -e child/.git/objects/tmp_test_object +' + rewound_push_setup() { rm -rf parent child && mkdir parent && |
