threads / patch / 38931

v2, 2 partsgit-p4: Make rename test case runnable under dash

Subject: [PATCH V2 1/2] git-p4: Make rename test case runnable under dash

## tl;dr

4 messages between Mar 28, 2015 and Mar 28, 2015. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Vitor Antunes· Mar 28, 2015, 00:03 UTC · lore

[PATCH V2 0/2] git-p4: Small updates to test cases

Updated both fixes:
1. Remove "true" from case statements and replaced it with ":".
2. Also use a case statement in the copy detection test to allow
   diff-tree to detect two different files as the origin of the
   copy. I've also reverted a change I introduced in the V1 patch
   that no longer makes much sense to me.
Vitor Antunes (2):
  git-p4: Make rename test case runnable under dash
  git-p4: Fix copy detection test
 t/t9814-git-p4-rename.sh |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
-- 
1.7.10.4
Vitor Antunes· Mar 28, 2015, 00:03 UTC · re: Vitor Antunes · lore
Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 t/t9814-git-p4-rename.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to t/t9814-git-p4-rename.sh +2 −2
diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
index 95f4421..efae143 100755
--- a/t/t9814-git-p4-rename.sh
+++ b/t/t9814-git-p4-rename.sh
@@ -180,7 +180,7 @@ test_expect_success 'detect copies' '
 		case "$src" in
 		file10 | file11) : ;; # happy
 		*) false ;; # not
-		&&
+		esac &&
 		git config git-p4.detectCopies $(($level + 2)) &&
 		git p4 submit &&
 		p4 filelog //depot/file12 &&
@@ -197,7 +197,7 @@ test_expect_success 'detect copies' '
 		case "$src" in
 		file10 | file11 | file12) : ;; # happy
 		*) false ;; # not
-		&&
+		esac &&
 		git config git-p4.detectCopies $(($level - 2)) &&
 		git p4 submit &&
 		p4 filelog //depot/file13 &&
-- 
1.7.10.4
Vitor Antunes· Mar 28, 2015, 00:03 UTC · re: Vitor Antunes · lore

[PATCH V2 2/2] git-p4: Fix copy detection test

File file11 is copied from file2 and diff-tree correctly reports this file as its the source. But it is possible that the diff-tree algorithm detects file10, which was also copied from file2, as the origin of the new file.

This fix uses a case statement to support both files as the source of file11, as was done in other tests in this file.

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 t/t9814-git-p4-rename.sh |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Show changes to t/t9814-git-p4-rename.sh +4 −1
diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
index efae143..8b9c295 100755
--- a/t/t9814-git-p4-rename.sh
+++ b/t/t9814-git-p4-rename.sh
@@ -163,7 +163,10 @@ test_expect_success 'detect copies' '
 		git commit -a -m "Copy file2 to file11" &&
 		git diff-tree -r -C --find-copies-harder HEAD &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		test "$src" = file10 &&
+		case "$src" in
+		file2 | file10) : ;; # happy
+		*) false ;; # not
+		esac &&
 		git config git-p4.detectCopiesHarder true &&
 		git p4 submit &&
 		p4 filelog //depot/file11 &&
-- 
1.7.10.4
Junio C Hamano· Mar 28, 2015, 16:07 UTC · re: Vitor Antunes · lore

Re: [PATCH V2 0/2] git-p4: Small updates to test cases

Will apply both.

It seems that I am to blame for 1/2 for botching the shell syntax X-<. Thanks for fixing.

I was not entirely happy with the "we could find either file10 or file11 because they are the same, so let's declare both are success" in the original, f69b3a93 (git p4 test: copy source indeterminate, 2012-06-27) in the first place, which survived the 9b6513ac (git p4 test: split up big t9800 test, 2012-06-27) and e832f737 (t9814: fix misconversion from test $a -o $b to test $a || test $b, 2014-07-25). I think a better fix would have been not to have multiple identical copies in the tested tree to begin with.

But 2/2 is an acceptable interim fix that uses the same approach as we have been using since f69b3a93, so it should do at least for now.

Thanks.

← back to recent threads