Skip to content

Commit 677b02c

Browse files
committed
fix tests compatibility issues with mksh
1 parent 2f4449a commit 677b02c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

git-core.spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Patch0: %{name}-key-bindings.patch
3030
Patch1: %{name}-sysconfdir.patch
3131
Patch2: cherry-picked-commitlog.patch
3232
Patch3: no-meson-test-check.patch
33+
Patch4: tests-mksh-compat.patch
3334
URL: http://git-scm.com/
3435
BuildRequires: autoconf >= 2.59
3536
BuildRequires: automake
@@ -453,6 +454,7 @@ Dopełnianie parametrów komendy git dla powłoki zsh.
453454
%patch -P1 -p1
454455
%patch -P2 -p1
455456
%patch -P3 -p1
457+
%patch -P4 -p1
456458

457459
# we build things in contrib but want to have it clean for doc purporses, too
458460
cp -a contrib contrib-doc

tests-mksh-compat.patch

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
From 17e4160cac5807e55057d88c4d53850c2a660ec6 Mon Sep 17 00:00:00 2001
2+
From: Jan Palus <jpalus@fastmail.com>
3+
Date: Sat, 11 Jan 2025 23:11:12 +0100
4+
Subject: [PATCH] t8002-blame: simplify padding generation in blank boundary
5+
tests
6+
7+
Fixes compatibility with mksh as well:
8+
$ mksh -c 'printf "%0.s" ""'
9+
printf: %0.s: invalid conversion specification
10+
11+
Fixes: e7fb2ca945 ("builtin/blame: fix out-of-bounds write with blank boundary commits")
12+
---
13+
t/t8002-blame.sh | 4 ++--
14+
1 file changed, 2 insertions(+), 2 deletions(-)
15+
16+
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
17+
index 1ad039e123..e98993276a 100755
18+
--- a/t/t8002-blame.sh
19+
+++ b/t/t8002-blame.sh
20+
@@ -138,7 +138,7 @@ test_expect_success 'blame --abbrev -b truncates the blank boundary' '
21+
# Note that `--abbrev=` always gets incremented by 1, which is why we
22+
# expect 11 leading spaces and not 10.
23+
cat >expect <<-EOF &&
24+
- $(printf "%0.s " $(test_seq 11)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
25+
+ $(printf "%11s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
26+
EOF
27+
git blame -b --abbrev=10 ^HEAD -- abbrev.t >actual &&
28+
test_cmp expect actual
29+
@@ -146,7 +146,7 @@ test_expect_success 'blame --abbrev -b truncates the blank boundary' '
30+
31+
test_expect_success 'blame with excessive --abbrev and -b culls to hash length' '
32+
cat >expect <<-EOF &&
33+
- $(printf "%0.s " $(test_seq $hexsz)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
34+
+ $(printf "%${hexsz}s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
35+
EOF
36+
git blame -b --abbrev=9000 ^HEAD -- abbrev.t >actual &&
37+
test_cmp expect actual
38+
--
39+
2.48.0
40+

0 commit comments

Comments
 (0)