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>
Matthieu Moy committed
Feb 25, 2016 at 09:59 UTC
a9276a69caeb116cf517a5feb70cd96efab23601
1 file changed
+60
-1
t/t4001-diff-rename.sh
+60
-1
@@ -27,7 +27,7 @@ test_expect_success 'setup' '
27
Line 14
28
Line 15
29
EOF
30
- cat >expected <<-\EOF
30
+ cat >expected <<-\EOF &&
31
diff --git a/path0 b/path1
32
rename from path0
33
rename to path1
@@ -43,6 +43,50 @@ test_expect_success 'setup' '
43
Line 13
44
Line 14
45
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
90
'
91
92
test_expect_success \
@@ -68,6 +112,21 @@ test_expect_success \
112
'validate the output.' \
113
'compare_diff_patch current expected'
114
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
+
130
test_expect_success 'favour same basenames over different ones' '
131
cp path1 another-path &&
132
git add another-path &&