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

4 messages from 2015-03-28 to 2015-03-28. Participants: Vitor Antunes, Junio C Hamano.
Thread: https://gitlist.dev/t/38931

## Vitor Antunes, 2015-03-28 00:03

Subject: [PATCH V2 0/2] git-p4: Small updates to test cases
Message-ID: <1427500983-8802-1-git-send-email-vitor.hda@gmail.com>
URL: https://gitlist.dev/e/1427500983-8802-1-git-send-email-vitor.hda%40gmail.com

```
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, 2015-03-28 00:03

Subject: [PATCH V2 1/2] git-p4: Make rename test case runnable under dash
Message-ID: <1427500983-8802-2-git-send-email-vitor.hda@gmail.com>
URL: https://gitlist.dev/e/1427500983-8802-2-git-send-email-vitor.hda%40gmail.com
In-Reply-To: <1427500983-8802-1-git-send-email-vitor.hda@gmail.com>

```

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 t/t9814-git-p4-rename.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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, 2015-03-28 00:03

Subject: [PATCH V2 2/2] git-p4: Fix copy detection test
Message-ID: <1427500983-8802-3-git-send-email-vitor.hda@gmail.com>
URL: https://gitlist.dev/e/1427500983-8802-3-git-send-email-vitor.hda%40gmail.com
In-Reply-To: <1427500983-8802-1-git-send-email-vitor.hda@gmail.com>

```
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(-)

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, 2015-03-28 16:07

Subject: Re: [PATCH V2 0/2] git-p4: Small updates to test cases
Message-ID: <xmqqa8yxyukb.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqa8yxyukb.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1427500983-8802-1-git-send-email-vitor.hda@gmail.com>

```
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.

```
