summaryrefslogtreecommitdiff
path: root/t/t5502-quickfetch.sh
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2009-07-10 01:52:30 +0200
committerJunio C Hamano <gitster@pobox.com>2009-07-10 23:53:17 -0700
commitd9eb0205a217984f3e70bf18ae66c02a22d3d475 (patch)
tree5c8b9b3ffdea99b34ee6f1ef3f9eeed7eafe0f3e /t/t5502-quickfetch.sh
parent7c74ff50626faca2fd302d83610494dd9106896d (diff)
downloadgit-d9eb0205a217984f3e70bf18ae66c02a22d3d475.tar.gz
quickfetch(): Prevent overflow of the rev-list command line
quickfetch() calls rev-list to check whether the objects we are about to fetch are already present in the repo (if so, we can skip the object fetch). However, when there are many (~1000) refs to be fetched, the rev-list command line grows larger than the maximum command line size on some systems (32K in Windows). This causes rev-list to fail, making quickfetch() return non-zero, which unnecessarily triggers the transport machinery. This somehow causes fetch to fail with an exit code. By using the --stdin option to rev-list (and feeding the object list to its standard input), we prevent the overflow of the rev-list command line, which causes quickfetch(), and subsequently the overall fetch, to succeed. However, using rev-list --stdin is not entirely straightforward: rev-list terminates immediately when encountering an unknown object, which can trigger SIGPIPE if we are still writing object's to its standard input. We therefore temporarily ignore SIGPIPE so that the fetch process is not terminated. The patch also contains a testcase to verify the fix (note that before the patch, the testcase would only fail on msysGit). Signed-off-by: Johan Herland <johan@herland.net> Improved-by: Johannes Sixt <j6t@kdbg.org> Improved-by: Alex Riesen <raa.lkml@gmail.com> Tested-by: Peter Krefting <peter@softwolves.pp.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5502-quickfetch.sh')
-rwxr-xr-xt/t5502-quickfetch.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh
index 16eadd6b68..1037a723fe 100755
--- a/t/t5502-quickfetch.sh
+++ b/t/t5502-quickfetch.sh
@@ -119,4 +119,24 @@ test_expect_success 'quickfetch should not copy from alternate' '
'
+test_expect_success 'quickfetch should handle ~1000 refs (on Windows)' '
+
+ git gc &&
+ head=$(git rev-parse HEAD) &&
+ branchprefix="$head refs/heads/branch" &&
+ for i in 0 1 2 3 4 5 6 7 8 9; do
+ for j in 0 1 2 3 4 5 6 7 8 9; do
+ for k in 0 1 2 3 4 5 6 7 8 9; do
+ echo "$branchprefix$i$j$k" >> .git/packed-refs
+ done
+ done
+ done &&
+ (
+ cd cloned &&
+ git fetch &&
+ git fetch
+ )
+
+'
+
test_done