aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-01-10 09:19:33 -0800
committerJunio C Hamano <gitster@pobox.com>2025-01-10 09:19:34 -0800
commitb28fb93e51a94907eca9cc08eb1a2db51fe1ddc8 (patch)
treeb3a173008e3703b170d3b2cff2253b0e1ef7506e /t
parent3ae35648bfc135e212c787f25caaed92ea7e0084 (diff)
parente7fb2ca94556e6aadfc3038afaa1c8cc3525258c (diff)
downloadgit-b28fb93e51a94907eca9cc08eb1a2db51fe1ddc8.tar.gz
Merge branch 'ps/build-sign-compare'
Last-minute fix for a regression in "git blame --abbrev=<length>" when insane <length> is specified; we used to correctly cap it to the hash output length but broke it during the cycle. * ps/build-sign-compare: builtin/blame: fix out-of-bounds write with blank boundary commits builtin/blame: fix out-of-bounds read with excessive `--abbrev`
Diffstat (limited to 't')
-rwxr-xr-xt/t8002-blame.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
index 0147de304b..1ad039e123 100755
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
@@ -126,6 +126,32 @@ test_expect_success '--no-abbrev works like --abbrev with full length' '
check_abbrev $hexsz --no-abbrev
'
+test_expect_success 'blame --abbrev gets truncated' '
+ check_abbrev $hexsz --abbrev=9000 HEAD
+'
+
+test_expect_success 'blame --abbrev gets truncated with boundary commit' '
+ check_abbrev $hexsz --abbrev=9000 ^HEAD
+'
+
+test_expect_success 'blame --abbrev -b truncates the blank boundary' '
+ # Note that `--abbrev=` always gets incremented by 1, which is why we
+ # expect 11 leading spaces and not 10.
+ cat >expect <<-EOF &&
+ $(printf "%0.s " $(test_seq 11)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
+ EOF
+ git blame -b --abbrev=10 ^HEAD -- abbrev.t >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'blame with excessive --abbrev and -b culls to hash length' '
+ cat >expect <<-EOF &&
+ $(printf "%0.s " $(test_seq $hexsz)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
+ EOF
+ git blame -b --abbrev=9000 ^HEAD -- abbrev.t >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '--exclude-promisor-objects does not BUG-crash' '
test_must_fail git blame --exclude-promisor-objects one
'