git-p4: Add test case for rename detection

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vitor Antunes committed Aug 22, 2011 at 09:33 UTC 52dced8a568a03d62ceff8e2cd9631074d08dca0
1 file changed +53
t/t9800-git-p4.sh
+53
@@ -269,6 +269,59 @@ test_expect_success 'initial import time from top change time' '
269 test $p4time = $gittime
270 '
271
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 +
325 test_expect_success 'shutdown' '
326 pid=`pgrep -f p4d` &&
327 test -n "$pid" &&