@matheusbsbs / matheus-bagliano / commits / 6517cf7de8
Fork 0

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 <kirr@landau.phys.spbu.ru> Reviewed-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kirill Smelkov committed Sep 29, 2010 at 15:35 UTC 6517cf7de8fe7a2b2c90655a79d11cba586a36e6
2 files changed +14 -12
t/t8006-blame-textconv.sh
+8 -7
@@ -9,22 +9,23 @@ find_blame() {
9
10 cat >helper <<'EOF'
11 #!/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"
14 EOF
15 chmod +x helper
16
17 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 &&
20 git add . &&
21 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 &&
24 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
25 '
26
27 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
29 EOF
30
31 test_expect_success 'no filter specified' '
@@ -67,7 +68,7 @@ test_expect_success 'blame --textconv going through revisions' '
68 '
69
70 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 &&
72 GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
73 '
74
t/t8007-cat-file-textconv.sh
+6 -5
@@ -5,15 +5,16 @@ test_description='git cat-file textconv support'
5
6 cat >helper <<'EOF'
7 #!/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"
10 EOF
11 chmod +x helper
12
13 test_expect_success 'setup ' '
13 - echo test >one.bin &&
14 + echo "bin: test" >one.bin &&
15 git add . &&
16 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 &&
18 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
19 '
20
@@ -33,7 +34,7 @@ test_expect_success 'setup textconv filters' '
34 '
35
36 cat >expected <<EOF
36 -test version 2
37 +bin: test version 2
38 EOF
39
40 test_expect_success 'cat-file without --textconv' '
@@ -42,7 +43,7 @@ test_expect_success 'cat-file without --textconv' '
43 '
44
45 cat >expected <<EOF
45 -test
46 +bin: test
47 EOF
48
49 test_expect_success 'cat-file without --textconv on previous commit' '