Skip to content

Commit 6517cf7

Browse files
navytuxgitster
authored andcommitted
blame,cat-file: Prepare --textconv tests for correctly-failing conversion program
The textconv filter is sometimes incorrectly ran on a temporary file whose content is the target of a symbolic link, instead of actual file content. Prepare to test this by marking the content of the file to convert with "bin:", and let the helper die if "bin:" is not found in the file content. NOTE: I've changed $@ to $1 in helper becase textconv program "should take a single argument" (see Documentation/gitattributes.txt), so making this more explicit makes sense and also helps to avoid problems with feeding arguments to echo. Signed-off-by: Kirill Smelkov <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d391c0f commit 6517cf7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

t/t8006-blame-textconv.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@ find_blame() {
99

1010
cat >helper <<'EOF'
1111
#!/bin/sh
12-
sed 's/^/converted: /' "$@"
12+
grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
13+
sed 's/^bin: /converted: /' "$1"
1314
EOF
1415
chmod +x helper
1516

1617
test_expect_success 'setup ' '
17-
echo test 1 >one.bin &&
18-
echo test number 2 >two.bin &&
18+
echo "bin: test 1" >one.bin &&
19+
echo "bin: test number 2" >two.bin &&
1920
git add . &&
2021
GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
21-
echo test 1 version 2 >one.bin &&
22-
echo test number 2 version 2 >>two.bin &&
22+
echo "bin: test 1 version 2" >one.bin &&
23+
echo "bin: test number 2 version 2" >>two.bin &&
2324
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
2425
'
2526

2627
cat >expected <<EOF
27-
(Number2 2010-01-01 20:00:00 +0000 1) test 1 version 2
28+
(Number2 2010-01-01 20:00:00 +0000 1) bin: test 1 version 2
2829
EOF
2930

3031
test_expect_success 'no filter specified' '
@@ -67,7 +68,7 @@ test_expect_success 'blame --textconv going through revisions' '
6768
'
6869

6970
test_expect_success 'make a new commit' '
70-
echo "test number 2 version 3" >>two.bin &&
71+
echo "bin: test number 2 version 3" >>two.bin &&
7172
GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
7273
'
7374

t/t8007-cat-file-textconv.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ test_description='git cat-file textconv support'
55

66
cat >helper <<'EOF'
77
#!/bin/sh
8-
sed 's/^/converted: /' "$@"
8+
grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
9+
sed 's/^bin: /converted: /' "$1"
910
EOF
1011
chmod +x helper
1112

1213
test_expect_success 'setup ' '
13-
echo test >one.bin &&
14+
echo "bin: test" >one.bin &&
1415
git add . &&
1516
GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
16-
echo test version 2 >one.bin &&
17+
echo "bin: test version 2" >one.bin &&
1718
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
1819
'
1920

@@ -33,7 +34,7 @@ test_expect_success 'setup textconv filters' '
3334
'
3435

3536
cat >expected <<EOF
36-
test version 2
37+
bin: test version 2
3738
EOF
3839

3940
test_expect_success 'cat-file without --textconv' '
@@ -42,7 +43,7 @@ test_expect_success 'cat-file without --textconv' '
4243
'
4344

4445
cat >expected <<EOF
45-
test
46+
bin: test
4647
EOF
4748

4849
test_expect_success 'cat-file without --textconv on previous commit' '

0 commit comments

Comments
 (0)