Skip to content

Commit 52dced8

Browse files
vhdagitster
authored andcommitted
git-p4: Add test case for rename detection
Signed-off-by: Vitor Antunes <[email protected]> Acked-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 807371a commit 52dced8

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

t/t9800-git-p4.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,59 @@ test_expect_success 'initial import time from top change time' '
269269
test $p4time = $gittime
270270
'
271271

272+
# Rename a file and confirm that rename is not detected in P4.
273+
# Rename the new file again with detectRenames option enabled and confirm that
274+
# this is detected in P4.
275+
# Rename the new file again adding an extra line, configure a big threshold in
276+
# detectRenames and confirm that rename is not detected in P4.
277+
# Repeat, this time with a smaller threshold and confirm that the rename is
278+
# detected in P4.
279+
test_expect_success 'detect renames' '
280+
"$GITP4" clone --dest="$git" //depot@all &&
281+
test_when_finished cleanup_git &&
282+
cd "$git" &&
283+
git config git-p4.skipSubmitEditCheck true &&
284+
285+
git mv file1 file4 &&
286+
git commit -a -m "Rename file1 to file4" &&
287+
git diff-tree -r -M HEAD &&
288+
"$GITP4" submit &&
289+
p4 filelog //depot/file4 &&
290+
! p4 filelog //depot/file4 | grep -q "branch from" &&
291+
292+
git mv file4 file5 &&
293+
git commit -a -m "Rename file4 to file5" &&
294+
git diff-tree -r -M HEAD &&
295+
git config git-p4.detectRenames true &&
296+
"$GITP4" submit &&
297+
p4 filelog //depot/file5 &&
298+
p4 filelog //depot/file5 | grep -q "branch from //depot/file4" &&
299+
300+
git mv file5 file6 &&
301+
echo update >>file6 &&
302+
git add file6 &&
303+
git commit -a -m "Rename file5 to file6 with changes" &&
304+
git diff-tree -r -M HEAD &&
305+
level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
306+
test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
307+
git config git-p4.detectRenames $((level + 2)) &&
308+
"$GITP4" submit &&
309+
p4 filelog //depot/file6 &&
310+
! p4 filelog //depot/file6 | grep -q "branch from" &&
311+
312+
git mv file6 file7 &&
313+
echo update >>file7 &&
314+
git add file7 &&
315+
git commit -a -m "Rename file6 to file7 with changes" &&
316+
git diff-tree -r -M HEAD &&
317+
level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
318+
test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
319+
git config git-p4.detectRenames $((level - 2)) &&
320+
"$GITP4" submit &&
321+
p4 filelog //depot/file7 &&
322+
p4 filelog //depot/file7 | grep -q "branch from //depot/file6"
323+
'
324+
272325
test_expect_success 'shutdown' '
273326
pid=`pgrep -f p4d` &&
274327
test -n "$pid" &&

0 commit comments

Comments
 (0)