summaryrefslogtreecommitdiff
path: root/t/t1506-rev-parse-diagnosis.sh
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2019-09-15 12:03:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-09-16 19:50:27 (GMT)
commita678df1bf928caeeef642ef07f73484a580fea57 (patch)
tree8819f7bf7cf61d6c5964e86bc7f7c173d11ae4d8 /t/t1506-rev-parse-diagnosis.sh
parent75b2f01a0f642b39b0f29b6218515df9b5eb798e (diff)
downloadgit-a678df1bf928caeeef642ef07f73484a580fea57.zip
git-a678df1bf928caeeef642ef07f73484a580fea57.tar.gz
git-a678df1bf928caeeef642ef07f73484a580fea57.tar.bz2
rev-parse: demonstrate overflow of N for "foo^N" and "foo~N"
If the number gets too high for an int, weird things may happen, as signed overflows are undefined. Add a test to show this; rev-parse "sucessfully" interprets 100000000000000000000000000000000 to be the same as 0, at least on x64 with GCC 9.2.1 and Clang 8.0.1, which is obviously bogus. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1506-rev-parse-diagnosis.sh')
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 4ee009d..5c4df47 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -215,4 +215,12 @@ test_expect_success 'arg before dashdash must be a revision (ambiguous)' '
test_cmp expect actual
'
+test_expect_failure 'reject Nth parent if N is too high' '
+ test_must_fail git rev-parse HEAD^100000000000000000000000000000000
+'
+
+test_expect_failure 'reject Nth ancestor if N is too high' '
+ test_must_fail git rev-parse HEAD~100000000000000000000000000000000
+'
+
test_done