From: René Scharfe Date: Sun, 15 Sep 2019 12:03:25 +0000 (+0200) Subject: rev-parse: demonstrate overflow of N for "foo^N" and "foo~N" X-Git-Tag: v2.24.0-rc0~75^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a678df1bf928caeeef642ef07f73484a580fea57;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index 4ee009da66..5c4df47401 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