@@ -48,7 +48,53 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' '
4848
4949'
5050
51+ test_expect_success SYMLINKS ' typechange diff' '
52+ rm -f file &&
53+ ln -s elif file &&
54+ GIT_EXTERNAL_DIFF=echo git diff | {
55+ read path oldfile oldhex oldmode newfile newhex newmode &&
56+ test "z$path" = zfile &&
57+ test "z$oldmode" = z100644 &&
58+ test "z$newhex" = "z$_z40" &&
59+ test "z$newmode" = z120000 &&
60+ oh=$(git rev-parse --verify HEAD:file) &&
61+ test "z$oh" = "z$oldhex"
62+ } &&
63+ GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff >actual &&
64+ git diff >expect &&
65+ test_cmp expect actual
66+ '
67+
68+ test_expect_success ' diff.external' '
69+ git reset --hard &&
70+ echo third >file &&
71+ test_config diff.external echo &&
72+ git diff | {
73+ read path oldfile oldhex oldmode newfile newhex newmode &&
74+ test "z$path" = zfile &&
75+ test "z$oldmode" = z100644 &&
76+ test "z$newhex" = "z$_z40" &&
77+ test "z$newmode" = z100644 &&
78+ oh=$(git rev-parse --verify HEAD:file) &&
79+ test "z$oh" = "z$oldhex"
80+ }
81+ '
82+
83+ test_expect_success ' diff.external should apply only to diff' '
84+ test_config diff.external echo &&
85+ git log -p -1 HEAD |
86+ grep "^diff --git a/file b/file"
87+ '
88+
89+ test_expect_success ' diff.external and --no-ext-diff' '
90+ test_config diff.external echo &&
91+ git diff --no-ext-diff |
92+ grep "^diff --git a/file b/file"
93+ '
94+
5195test_expect_success ' diff attribute' '
96+ git reset --hard &&
97+ echo third >file &&
5298
5399 git config diff.parrot.command echo &&
54100
@@ -113,6 +159,19 @@ test_expect_success 'diff attribute and --no-ext-diff' '
113159
114160'
115161
162+ test_expect_success ' GIT_EXTERNAL_DIFF trumps diff.external' '
163+ >.gitattributes &&
164+ test_config diff.external "echo ext-global" &&
165+ GIT_EXTERNAL_DIFF="echo ext-env" git diff | grep ext-env
166+ '
167+
168+ test_expect_success ' attributes trump GIT_EXTERNAL_DIFF and diff.external' '
169+ test_config diff.foo.command "echo ext-attribute" &&
170+ test_config diff.external "echo ext-global" &&
171+ echo "file diff=foo" >.gitattributes &&
172+ GIT_EXTERNAL_DIFF="echo ext-env" git diff | grep ext-attribute
173+ '
174+
116175test_expect_success ' no diff with -diff' '
117176 echo >.gitattributes "file -diff" &&
118177 git diff | grep Binary
0 commit comments