Merge branch 'fixes/2.45.1/2.41' into fixes/2.45.1/2.42
[alt-git.git] / t / t4029-diff-trailing-space.sh
blob5f8ffef74b6474c9fb97e18cd6c48d449fa26734
1 #!/bin/sh
3 # Copyright (c) Jim Meyering
5 test_description='diff honors config option, diff.suppressBlankEmpty'
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 cat <<\EOF >expected ||
11 diff --git a/f b/f
12 index 5f6a263..8cb8bae 100644
13 --- a/f
14 +++ b/f
15 @@ -1,2 +1,2 @@
19 EOF
20 exit 1
22 test_expect_success "$test_description" '
23 printf "\nx\n" > f &&
24 before=$(git hash-object f) &&
25 before=$(git rev-parse --short $before) &&
26 git add f &&
27 git commit -q -m. f &&
28 printf "\ny\n" > f &&
29 after=$(git hash-object f) &&
30 after=$(git rev-parse --short $after) &&
31 sed -e "s/^index .*/index $before..$after 100644/" expected >exp &&
32 git config --bool diff.suppressBlankEmpty true &&
33 git diff f > actual &&
34 test_cmp exp actual &&
35 perl -i.bak -p -e "s/^\$/ /" exp &&
36 git config --bool diff.suppressBlankEmpty false &&
37 git diff f > actual &&
38 test_cmp exp actual &&
39 git config --bool --unset diff.suppressBlankEmpty &&
40 git diff f > actual &&
41 test_cmp exp actual
44 test_done