Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano |
| 4 | # |
| 5 | |
| 6 | test_description='Test built-in diff output engine. |
| 7 | |
| 8 | ' |
| 9 | . ./test-lib.sh |
Junio C Hamano | bfdbee9 | 2008-08-08 02:26:28 -0700 | [diff] [blame] | 10 | . "$TEST_DIRECTORY"/diff-lib.sh |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 11 | |
| 12 | echo >path0 'Line 1 |
| 13 | Line 2 |
| 14 | line 3' |
| 15 | cat path0 >path1 |
| 16 | chmod +x path1 |
| 17 | |
Matthieu Moy | 8ade9b1 | 2013-07-16 10:05:35 +0200 | [diff] [blame] | 18 | test_expect_success 'update-index --add two files with and without +x.' ' |
| 19 | git update-index --add path0 path1 |
| 20 | ' |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 21 | |
| 22 | mv path0 path0- |
| 23 | sed -e 's/line/Line/' <path0- >path0 |
| 24 | chmod +x path0 |
| 25 | rm -f path1 |
Matthieu Moy | 8ade9b1 | 2013-07-16 10:05:35 +0200 | [diff] [blame] | 26 | test_expect_success 'git diff-files -p after editing work tree.' ' |
| 27 | git diff-files -p >actual |
| 28 | ' |
Alex Riesen | e58b97a | 2006-01-05 12:55:03 +0100 | [diff] [blame] | 29 | |
| 30 | # that's as far as it comes |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 31 | if [ "$(git config --get core.filemode)" = false ] |
Alex Riesen | e58b97a | 2006-01-05 12:55:03 +0100 | [diff] [blame] | 32 | then |
| 33 | say 'filemode disabled on the filesystem' |
| 34 | test_done |
| 35 | fi |
| 36 | |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 37 | cat >expected <<\EOF |
Junio C Hamano | b58f23b | 2005-05-18 09:10:47 -0700 | [diff] [blame] | 38 | diff --git a/path0 b/path0 |
| 39 | old mode 100644 |
| 40 | new mode 100755 |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 41 | --- a/path0 |
| 42 | +++ b/path0 |
| 43 | @@ -1,3 +1,3 @@ |
| 44 | Line 1 |
| 45 | Line 2 |
| 46 | -line 3 |
| 47 | +Line 3 |
Junio C Hamano | b58f23b | 2005-05-18 09:10:47 -0700 | [diff] [blame] | 48 | diff --git a/path1 b/path1 |
| 49 | deleted file mode 100755 |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 50 | --- a/path1 |
| 51 | +++ /dev/null |
| 52 | @@ -1,3 +0,0 @@ |
| 53 | -Line 1 |
| 54 | -Line 2 |
| 55 | -line 3 |
| 56 | EOF |
| 57 | |
Matthieu Moy | 8ade9b1 | 2013-07-16 10:05:35 +0200 | [diff] [blame] | 58 | test_expect_success 'validate git diff-files -p output.' ' |
| 59 | compare_diff_patch expected actual |
| 60 | ' |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 61 | |
Matthieu Moy | d09cd15 | 2013-07-16 10:05:36 +0200 | [diff] [blame] | 62 | test_expect_success 'git diff-files -s after editing work tree' ' |
| 63 | git diff-files -s >actual 2>err && |
| 64 | test_must_be_empty actual && |
| 65 | test_must_be_empty err |
| 66 | ' |
| 67 | |
| 68 | test_expect_success 'git diff-files --no-patch as synonym for -s' ' |
| 69 | git diff-files --no-patch >actual 2>err && |
| 70 | test_must_be_empty actual && |
| 71 | test_must_be_empty err |
| 72 | ' |
| 73 | |
Matthieu Moy | 71482d3 | 2013-07-16 10:05:37 +0200 | [diff] [blame] | 74 | test_expect_success 'git diff-files --no-patch --patch shows the patch' ' |
| 75 | git diff-files --no-patch --patch >actual && |
| 76 | compare_diff_patch expected actual |
| 77 | ' |
| 78 | |
| 79 | test_expect_success 'git diff-files --no-patch --patch-with-raw shows the patch and raw data' ' |
| 80 | git diff-files --no-patch --patch-with-raw >actual && |
| 81 | grep -q "^:100644 100755 .* 0000000000000000000000000000000000000000 M path0\$" actual && |
| 82 | tail -n +4 actual >actual-patch && |
| 83 | compare_diff_patch expected actual-patch |
| 84 | ' |
| 85 | |
| 86 | test_expect_success 'git diff-files --patch --no-patch does not show the patch' ' |
| 87 | git diff-files --patch --no-patch >actual 2>err && |
| 88 | test_must_be_empty actual && |
| 89 | test_must_be_empty err |
| 90 | ' |
| 91 | |
Junio C Hamano | 13ab446 | 2005-05-13 22:52:42 -0700 | [diff] [blame] | 92 | test_done |