Skip to content

Commit b174eb4

Browse files
apelissegitster
authored andcommitted
tests: make sure rename pretty print works
Add basic use cases and corner cases tests for "git diff -M --summary/stat". Signed-off-by: Antoine Pelisse <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dd281f0 commit b174eb4

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

t/t4001-diff-rename.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,58 @@ test_expect_success 'setup for many rename source candidates' '
102102
grep warning actual.err
103103
'
104104

105+
test_expect_success 'rename pretty print with nothing in common' '
106+
mkdir -p a/b/ &&
107+
: >a/b/c &&
108+
git add a/b/c &&
109+
git commit -m "create a/b/c" &&
110+
mkdir -p c/b/ &&
111+
git mv a/b/c c/b/a &&
112+
git commit -m "a/b/c -> c/b/a" &&
113+
git diff -M --summary HEAD^ HEAD >output &&
114+
test_i18ngrep " a/b/c => c/b/a " output &&
115+
git diff -M --stat HEAD^ HEAD >output &&
116+
test_i18ngrep " a/b/c => c/b/a " output
117+
'
118+
119+
test_expect_success 'rename pretty print with common prefix' '
120+
mkdir -p c/d &&
121+
git mv c/b/a c/d/e &&
122+
git commit -m "c/b/a -> c/d/e" &&
123+
git diff -M --summary HEAD^ HEAD >output &&
124+
test_i18ngrep " c/{b/a => d/e} " output &&
125+
git diff -M --stat HEAD^ HEAD >output &&
126+
test_i18ngrep " c/{b/a => d/e} " output
127+
'
128+
129+
test_expect_success 'rename pretty print with common suffix' '
130+
mkdir d &&
131+
git mv c/d/e d/e &&
132+
git commit -m "c/d/e -> d/e" &&
133+
git diff -M --summary HEAD^ HEAD >output &&
134+
test_i18ngrep " {c/d => d}/e " output &&
135+
git diff -M --stat HEAD^ HEAD >output &&
136+
test_i18ngrep " {c/d => d}/e " output
137+
'
138+
139+
test_expect_success 'rename pretty print with common prefix and suffix' '
140+
mkdir d/f &&
141+
git mv d/e d/f/e &&
142+
git commit -m "d/e -> d/f/e" &&
143+
git diff -M --summary HEAD^ HEAD >output &&
144+
test_i18ngrep " d/{ => f}/e " output &&
145+
git diff -M --stat HEAD^ HEAD >output &&
146+
test_i18ngrep " d/{ => f}/e " output
147+
'
148+
149+
test_expect_success 'rename pretty print common prefix and suffix overlap' '
150+
mkdir d/f/f &&
151+
git mv d/f/e d/f/f/e &&
152+
git commit -m "d/f/e d/f/f/e" &&
153+
git diff -M --summary HEAD^ HEAD >output &&
154+
test_i18ngrep " d/f/{ => f}/e " output &&
155+
git diff -M --stat HEAD^ HEAD >output &&
156+
test_i18ngrep " d/f/{ => f}/e " output
157+
'
158+
105159
test_done

0 commit comments

Comments
 (0)