git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH FYI] t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0'

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 19, 2008, 00:13 UTC
Message-ID
<Fw5U6bbeAwsJt8NPEGhI_KJGqviiUs1rv931TtDgSG2zzNctlxMWYA@cipher.nrlssc.navy.mil>
In-Reply-To
<IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil>

Some old platforms have an old diff which doesn't have the -U option. 'git diff' can be used in its place. Adjust the comparison function to strip git's additional header lines to make this possible. ---

Same as the one posted in the IRIX thread.
 t/t1002-read-tree-m-u-2way.sh |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
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.6.0.11.gecc7e
Previous: Brandon CaseyNext: Brandon Casey
Message 21 of 36 in “[FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh”
  1. Brandon CaseyAug 18, 2008
  2. Makefile: configuration for SunOS 5.7Brandon Casey, Aug 18, 2008
  3. dir.c: avoid c99 array initializationBrandon Casey, Aug 18, 2008
  4. David KågedalAug 28, 2008
  5. Andreas EricssonAug 28, 2008
  6. Brandon CaseyAug 28, 2008
  7. Junio C HamanoAug 28, 2008
  8. Brandon CaseyAug 28, 2008
  9. Alex RiesenAug 28, 2008
  10. Brandon CaseyAug 28, 2008
  11. Alex RiesenAug 28, 2008
  12. Shawn O. PearceAug 28, 2008
  13. Junio C HamanoAug 28, 2008
  14. dir.c: Avoid c99 array initializationBrandon Casey, Aug 28, 2008
  15. Alex RiesenAug 28, 2008
  16. Brandon CaseyAug 28, 2008
  17. Alex RiesenAug 28, 2008
  18. Johannes SchindelinAug 29, 2008
  19. reset,cat-file: remove const declaration from arrayBrandon Casey, Aug 19, 2008
  20. test-lib.sh: work around ksh's trap shortcomingsBrandon Casey, Aug 19, 2008
  21. t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0'Brandon Casey, Aug 19, 2008
  22. Work around sed issuesBrandon Casey, Aug 19, 2008
  23. t9301-fast-export.sh: don't unset config variable while we're skipping test 4Brandon Casey, Aug 19, 2008
  24. Jeff KingAug 19, 2008
  25. Brandon CaseyAug 19, 2008
  26. Jeff KingAug 19, 2008
  27. t9700/test.pl: backwards compatibility improvementsBrandon Casey, Aug 19, 2008
  28. Tom G. ChristensenSep 15, 2008
  29. Brandon CaseySep 15, 2008
  30. Brandon CaseySep 15, 2008
  31. 1/3 t9700/test.pl: no longer requires File::BasenameBrandon Casey, Sep 15, 2008
  32. 2/3 t9700/test.pl: avoid bareword 'STDERR' in 3-argument open()Brandon Casey, Sep 15, 2008
  33. 3/3 t9700/test.pl: remove File::Temp requirementBrandon Casey, Sep 15, 2008
  34. Tom G. ChristensenSep 15, 2008
  35. Alex RiesenAug 19, 2008
  36. Brandon CaseyAug 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.