git-p4: Small updates to test cases
v2 cover 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(-)
Signature · 1 line
1.7.10.4
PATCH v2 1/2 git-p4: Make rename test case runnable under dash
--- t/t9814-git-p4-rename.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
t/t9814-git-p4-rename.sh +2 -2
@@ -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 &&
Signature · 1 line
1.7.10.4
PATCH v2 2/2 git-p4: Fix copy detection test
In reply to Vitor AntunesFile 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.
--- t/t9814-git-p4-rename.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
t/t9814-git-p4-rename.sh +4 -1
@@ -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 &&
Signature · 1 line
1.7.10.4
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.