Skip to content

Commit a9276a6

Browse files
moygitster
authored andcommitted
t: add tests for diff.renames (true/false/unset)
The underlying machinery is well-tested, but the configuration option itself was tested only in t3400-rebase.sh. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent f07fc9e commit a9276a6

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

t/t4001-diff-rename.sh

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_expect_success 'setup' '
2727
Line 14
2828
Line 15
2929
EOF
30-
cat >expected <<-\EOF
30+
cat >expected <<-\EOF &&
3131
diff --git a/path0 b/path1
3232
rename from path0
3333
rename to path1
@@ -43,6 +43,50 @@ test_expect_success 'setup' '
4343
Line 13
4444
Line 14
4545
EOF
46+
cat >no-rename <<-\EOF
47+
diff --git a/path0 b/path0
48+
deleted file mode 100644
49+
index fdbec44..0000000
50+
--- a/path0
51+
+++ /dev/null
52+
@@ -1,15 +0,0 @@
53+
-Line 1
54+
-Line 2
55+
-Line 3
56+
-Line 4
57+
-Line 5
58+
-Line 6
59+
-Line 7
60+
-Line 8
61+
-Line 9
62+
-Line 10
63+
-line 11
64+
-Line 12
65+
-Line 13
66+
-Line 14
67+
-Line 15
68+
diff --git a/path1 b/path1
69+
new file mode 100644
70+
index 0000000..752c50e
71+
--- /dev/null
72+
+++ b/path1
73+
@@ -0,0 +1,15 @@
74+
+Line 1
75+
+Line 2
76+
+Line 3
77+
+Line 4
78+
+Line 5
79+
+Line 6
80+
+Line 7
81+
+Line 8
82+
+Line 9
83+
+Line 10
84+
+Line 11
85+
+Line 12
86+
+Line 13
87+
+Line 14
88+
+Line 15
89+
EOF
4690
'
4791

4892
test_expect_success \
@@ -68,6 +112,21 @@ test_expect_success \
68112
'validate the output.' \
69113
'compare_diff_patch current expected'
70114

115+
test_expect_success 'test diff.renames=true' '
116+
git -c diff.renames=true diff --cached $tree >current &&
117+
compare_diff_patch current expected
118+
'
119+
120+
test_expect_success 'test diff.renames=false' '
121+
git -c diff.renames=false diff --cached $tree >current &&
122+
compare_diff_patch current no-rename
123+
'
124+
125+
test_expect_success 'test diff.renames unset' '
126+
git diff --cached $tree >current &&
127+
compare_diff_patch current no-rename
128+
'
129+
71130
test_expect_success 'favour same basenames over different ones' '
72131
cp path1 another-path &&
73132
git add another-path &&

0 commit comments

Comments
 (0)