[PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

Subsystems: the rest

STALE3707d

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

From: Brandon Casey <hidden>
Date: 2016-06-15 22:44:59

Signed-off-by: Brandon Casey <redacted>
---
 t/t0002-gitfile.sh               |    2 +-
 t/t1002-read-tree-m-u-2way.sh    |   12 ++++++------
 t/t2201-add-update-typechange.sh |   10 +++++-----
 3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index c5dbc72..4db4ac4 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -66,7 +66,7 @@ test_expect_success 'check hash-object' '
 
 test_expect_success 'check cat-file' '
 	git cat-file blob $SHA >actual &&
-	diff -u bar actual
+	test_cmp bar actual
 '
 
 test_expect_success 'check update-index' '
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index e04990e..aa9dd58 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -112,7 +112,7 @@ test_expect_success \
      git update-index --add frotz &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >6.out &&
-     diff -U0 M.out 6.out &&
+     test_cmp M.out 6.out &&
      check_cache_at frotz clean &&
      sum bozbar frotz nitfol >actual3.sum &&
      cmp M.sum actual3.sum &&
@@ -129,7 +129,7 @@ test_expect_success \
      echo frotz frotz >frotz &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >7.out &&
-     diff -U0 M.out 7.out &&
+     test_cmp M.out 7.out &&
      check_cache_at frotz dirty &&
      sum bozbar frotz nitfol >actual7.sum &&
      if cmp M.sum actual7.sum; then false; else :; fi &&
@@ -264,7 +264,7 @@ test_expect_success \
      git update-index --add bozbar &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >18.out &&
-     diff -U0 M.out 18.out &&
+     test_cmp M.out 18.out &&
      check_cache_at bozbar clean &&
      sum bozbar frotz nitfol >actual18.sum &&
      cmp M.sum actual18.sum'
@@ -278,7 +278,7 @@ test_expect_success \
      echo gnusto gnusto >bozbar &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >19.out &&
-     diff -U0 M.out 19.out &&
+     test_cmp M.out 19.out &&
      check_cache_at bozbar dirty &&
      sum frotz nitfol >actual19.sum &&
      grep -v bozbar  M.sum > expected19.sum &&
@@ -297,7 +297,7 @@ test_expect_success \
      git update-index --add bozbar &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >20.out &&
-     diff -U0 M.out 20.out &&
+     test_cmp M.out 20.out &&
      check_cache_at bozbar clean &&
      sum bozbar frotz nitfol >actual20.sum &&
      cmp M.sum actual20.sum'
@@ -338,7 +338,7 @@ test_expect_success \
      git update-index --add DF &&
      git read-tree -m -u $treeDF $treeDFDF &&
      git ls-files --stage >DFDFcheck.out &&
-     diff -U0 DFDF.out DFDFcheck.out &&
+     test_cmp DFDF.out DFDFcheck.out &&
      check_cache_at DF/DF clean'
 
 test_done
diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh
index e15e3eb..d24c7d9 100755
--- a/t/t2201-add-update-typechange.sh
+++ b/t/t2201-add-update-typechange.sh
@@ -106,12 +106,12 @@ test_expect_success modify '
 
 test_expect_success diff-files '
 	git diff-files --raw >actual &&
-	diff -u expect-files actual
+	test_cmp expect-files actual
 '
 
 test_expect_success diff-index '
 	git diff-index --raw HEAD -- >actual &&
-	diff -u expect-index actual
+	test_cmp expect-index actual
 '
 
 test_expect_success 'add -u' '
@@ -119,7 +119,7 @@ test_expect_success 'add -u' '
 	cp -p ".git/index" ".git/saved-index" &&
 	git add -u &&
 	git ls-files -s >actual &&
-	diff -u expect-final actual
+	test_cmp expect-final actual
 '
 
 test_expect_success 'commit -a' '
@@ -130,11 +130,11 @@ test_expect_success 'commit -a' '
 	fi &&
 	git commit -m "second" -a &&
 	git ls-files -s >actual &&
-	diff -u expect-final actual &&
+	test_cmp expect-final actual &&
 	rm -f .git/index &&
 	git read-tree HEAD &&
 	git ls-files -s >actual &&
-	diff -u expect-final actual
+	test_cmp expect-final actual
 '
 
 test_done
-- 
1.6.0.rc0.38.g8b8fb7

Re: [PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

From: Miklos Vajna <hidden>
Date: 2016-06-15 22:45:00

On Tue, Jul 22, 2008 at 04:17:43PM -0500, Brandon Casey [off-list ref] wrote:
 t/t0002-gitfile.sh               |    2 +-
 t/t1002-read-tree-m-u-2way.sh    |   12 ++++++------
 t/t2201-add-update-typechange.sh |   10 +++++-----
 3 files changed, 12 insertions(+), 12 deletions(-)
Hmm, after applying this patch, I have:

~/git/t$ git grep 'diff -U'
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 4.out >4diff.out
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 5.out >5diff.out
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 14.out >14diff.out
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 15.out >15diff.out

Any reason you left this out? ;-)

Re: [PATCH] t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff

From: Brandon Casey <hidden>
Date: 2016-06-15 22:45:00

Miklos Vajna wrote:
On Tue, Jul 22, 2008 at 04:17:43PM -0500, Brandon Casey [off-list ref] wrote:
quoted
 t/t0002-gitfile.sh               |    2 +-
 t/t1002-read-tree-m-u-2way.sh    |   12 ++++++------
 t/t2201-add-update-typechange.sh |   10 +++++-----
 3 files changed, 12 insertions(+), 12 deletions(-)
Hmm, after applying this patch, I have:

~/git/t$ git grep 'diff -U'
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 4.out >4diff.out
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 5.out >5diff.out
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 14.out >14diff.out
t1002-read-tree-m-u-2way.sh:     diff -U0 M.out 15.out >15diff.out

Any reason you left this out? ;-)
I have the patch below in my repo so I can run this test. (copy/pasted
and white-space corrupted since I haven't figured out how to reply to a
message and import a patch correctly using thunderbird).

As you can see I just replaced the 'diff -U0' with 'git diff -U0' and then
stripped off the git bits from the diff in the compare_change() function.

I think there is probably a better way to fix this, so I left it out.

Thinking about it now, it would have made sense to hold off on the part of
the patch I submitted which applies to t1002-read-tree-m-u-2way.sh until I
had a solution for the rest of these 'diff -U0's.

-brandon

diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index aa9dd58..5e40cec 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -14,6 +14,8 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 compare_change () {
        sed >current \
+           -e '1{/^diff --git /d;}' \
+           -e '2{/^index /d;}' \
            -e '/^--- /d; /^+++ /d; /^@@ /d;' \
            -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
        test_cmp expected current
@@ -75,7 +77,7 @@ test_expect_success \
      git update-index --add yomin &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >4.out || return 1
-     diff -U0 M.out 4.out >4diff.out
+     git diff -U0 --no-index M.out 4.out >4diff.out
      compare_change 4diff.out expected &&
      check_cache_at yomin clean &&
      sum bozbar frotz nitfol >actual4.sum &&
@@ -94,7 +96,7 @@ test_expect_success \
      echo yomin yomin >yomin &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >5.out || return 1
-     diff -U0 M.out 5.out >5diff.out
+     git diff -U0 --no-index M.out 5.out >5diff.out
      compare_change 5diff.out expected &&
      check_cache_at yomin dirty &&
      sum bozbar frotz nitfol >actual5.sum &&
@@ -206,7 +208,7 @@ test_expect_success \
      git update-index --add nitfol &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >14.out || return 1
-     diff -U0 M.out 14.out >14diff.out
+     git diff -U0 --no-index M.out 14.out >14diff.out
      compare_change 14diff.out expected &&
      sum bozbar frotz >actual14.sum &&
      grep -v nitfol M.sum > expected14.sum &&
@@ -227,7 +229,7 @@ test_expect_success \
      echo nitfol nitfol nitfol >nitfol &&
      git read-tree -m -u $treeH $treeM &&
      git ls-files --stage >15.out || return 1
-     diff -U0 M.out 15.out >15diff.out
+     git diff -U0 --no-index M.out 15.out >15diff.out
      compare_change 15diff.out expected &&
      check_cache_at nitfol dirty &&
      sum bozbar frotz >actual15.sum &&
-- 
1.5.6.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help