aboutsummaryrefslogtreecommitdiff
path: root/t/t7004-tag.sh
diff options
context:
space:
mode:
authorJean-Jacques Lafay <jeanjacques.lafay@gmail.com>2014-04-24 14:24:39 +0200
committerJunio C Hamano <gitster@pobox.com>2014-04-25 09:35:20 -0700
commitcbc60b67201e083a4970c8731c5382a575357e36 (patch)
tree3272cd96773c56c647a03c3bf0f46f784eda4a32 /t/t7004-tag.sh
parent779792a5f24bb4e8049c4f88ad752e70d4a8a080 (diff)
downloadgit-cbc60b67201e083a4970c8731c5382a575357e36.tar.gz
git-cbc60b67201e083a4970c8731c5382a575357e36.tar.xz
git tag --contains: avoid stack overflow
In large repos, the recursion implementation of contains(commit, commit_list) may result in a stack overflow. Replace the recursion with a loop to fix it. This problem is more apparent on Windows than on Linux, where the stack is more limited by default. See also this thread on the msysGit list: https://groups.google.com/d/topic/msysgit/FqT6boJrb2g/discussion [jes: re-written to imitate the original recursion more closely] Thomas Braun pointed out several documentation shortcomings. Tests are run only if ulimit -s is available. This means they cannot be run on Windows. Signed-off-by: Jean-Jacques Lafay <jeanjacques.lafay@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Tested-by: Stepan Kasal <kasal@ucw.cz> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7004-tag.sh')
-rwxr-xr-xt/t7004-tag.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 143a8ea60..e4ab0f5b6 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1423,4 +1423,30 @@ EOF
test_cmp expect actual
'
+run_with_limited_stack () {
+ (ulimit -s 64 && "$@")
+}
+
+test_lazy_prereq ULIMIT 'run_with_limited_stack true'
+
+# we require ulimit, this excludes Windows
+test_expect_success ULIMIT '--contains works in a deep repo' '
+ >expect &&
+ i=1 &&
+ while test $i -lt 4000
+ do
+ echo "commit refs/heads/master
+committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200
+data <<EOF
+commit #$i
+EOF"
+ test $i = 1 && echo "from refs/heads/master^0"
+ i=$(($i + 1))
+ done | git fast-import &&
+ git checkout master &&
+ git tag far-far-away HEAD^ &&
+ run_with_limited_stack git tag --contains HEAD >actual &&
+ test_cmp expect actual
+'
+
test_done