Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Return value of diffs' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup' ' |
| 8 | echo 1 >a && |
| 9 | git add . && |
| 10 | git commit -m first && |
| 11 | echo 2 >b && |
| 12 | git add . && |
Tim Henigan | 304970d | 2012-06-21 14:09:51 -0400 | [diff] [blame] | 13 | git commit -a -m second && |
| 14 | mkdir -p test-outside/repo && ( |
| 15 | cd test-outside/repo && |
| 16 | git init && |
| 17 | echo "1 1" >a && |
| 18 | git add . && |
| 19 | git commit -m 1 |
| 20 | ) && |
| 21 | mkdir -p test-outside/non/git && ( |
| 22 | cd test-outside/non/git && |
| 23 | echo "1 1" >a && |
| 24 | echo "1 1" >matching-file && |
| 25 | echo "1 1 " >trailing-space && |
| 26 | echo "1 1" >extra-space && |
| 27 | echo "2" >never-match |
| 28 | ) |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 29 | ' |
| 30 | |
| 31 | test_expect_success 'git diff-tree HEAD^ HEAD' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 32 | test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt && |
| 33 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 34 | ' |
| 35 | test_expect_success 'git diff-tree HEAD^ HEAD -- a' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 36 | test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt && |
| 37 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 38 | ' |
| 39 | test_expect_success 'git diff-tree HEAD^ HEAD -- b' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 40 | test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt && |
| 41 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 42 | ' |
| 43 | # this diff outputs one line: sha1 of the given head |
| 44 | test_expect_success 'echo HEAD | git diff-tree --stdin' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 45 | echo $(git rev-parse HEAD) | |
| 46 | test_expect_code 1 git diff-tree --quiet --stdin >cnt && |
| 47 | test_line_count = 1 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 48 | ' |
| 49 | test_expect_success 'git diff-tree HEAD HEAD' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 50 | test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt && |
| 51 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 52 | ' |
| 53 | test_expect_success 'git diff-files' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 54 | test_expect_code 0 git diff-files --quiet >cnt && |
| 55 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 56 | ' |
| 57 | test_expect_success 'git diff-index --cached HEAD' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 58 | test_expect_code 0 git diff-index --quiet --cached HEAD >cnt && |
| 59 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 60 | ' |
| 61 | test_expect_success 'git diff-index --cached HEAD^' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 62 | test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt && |
| 63 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 64 | ' |
| 65 | test_expect_success 'git diff-index --cached HEAD^' ' |
| 66 | echo text >>b && |
| 67 | echo 3 >c && |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 68 | git add . && |
| 69 | test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt && |
| 70 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 71 | ' |
| 72 | test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 73 | git commit -m "text in b" && |
| 74 | test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt && |
| 75 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 76 | ' |
| 77 | test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 78 | test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt && |
| 79 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 80 | ' |
| 81 | test_expect_success 'git diff-files' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 82 | echo 3 >>c && |
| 83 | test_expect_code 1 git diff-files --quiet >cnt && |
| 84 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 85 | ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 86 | |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 87 | test_expect_success 'git diff-index --cached HEAD' ' |
Jeff King | c21fc9d | 2015-03-20 06:11:46 -0400 | [diff] [blame] | 88 | git update-index c && |
| 89 | test_expect_code 1 git diff-index --quiet --cached HEAD >cnt && |
| 90 | test_line_count = 0 cnt |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 91 | ' |
| 92 | |
Tim Henigan | 304970d | 2012-06-21 14:09:51 -0400 | [diff] [blame] | 93 | test_expect_success 'git diff, one file outside repo' ' |
| 94 | ( |
| 95 | cd test-outside/repo && |
| 96 | test_expect_code 0 git diff --quiet a ../non/git/matching-file && |
| 97 | test_expect_code 1 git diff --quiet a ../non/git/extra-space |
| 98 | ) |
| 99 | ' |
| 100 | |
| 101 | test_expect_success 'git diff, both files outside repo' ' |
| 102 | ( |
| 103 | GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" && |
| 104 | export GIT_CEILING_DIRECTORIES && |
| 105 | cd test-outside/non/git && |
| 106 | test_expect_code 0 git diff --quiet a matching-file && |
| 107 | test_expect_code 1 git diff --quiet a extra-space |
| 108 | ) |
| 109 | ' |
| 110 | |
| 111 | test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' ' |
| 112 | ( |
| 113 | cd test-outside/repo && |
| 114 | test_expect_code 0 git diff --quiet --ignore-space-at-eol a ../non/git/trailing-space && |
| 115 | test_expect_code 1 git diff --quiet --ignore-space-at-eol a ../non/git/extra-space |
| 116 | ) |
| 117 | ' |
| 118 | |
| 119 | test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' ' |
| 120 | ( |
| 121 | GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" && |
| 122 | export GIT_CEILING_DIRECTORIES && |
| 123 | cd test-outside/non/git && |
| 124 | test_expect_code 0 git diff --quiet --ignore-space-at-eol a trailing-space && |
| 125 | test_expect_code 1 git diff --quiet --ignore-space-at-eol a extra-space |
| 126 | ) |
| 127 | ' |
| 128 | |
| 129 | test_expect_success 'git diff --ignore-all-space, one file outside repo' ' |
| 130 | ( |
| 131 | cd test-outside/repo && |
| 132 | test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/trailing-space && |
| 133 | test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/extra-space && |
| 134 | test_expect_code 1 git diff --quiet --ignore-all-space a ../non/git/never-match |
| 135 | ) |
| 136 | ' |
| 137 | |
| 138 | test_expect_success 'git diff --ignore-all-space, both files outside repo' ' |
| 139 | ( |
| 140 | GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" && |
| 141 | export GIT_CEILING_DIRECTORIES && |
| 142 | cd test-outside/non/git && |
| 143 | test_expect_code 0 git diff --quiet --ignore-all-space a trailing-space && |
| 144 | test_expect_code 0 git diff --quiet --ignore-all-space a extra-space && |
| 145 | test_expect_code 1 git diff --quiet --ignore-all-space a never-match |
| 146 | ) |
| 147 | ' |
| 148 | |
Nguyễn Thái Ngọc Duy | f34b205 | 2014-01-25 13:46:50 +0700 | [diff] [blame] | 149 | test_expect_success 'git diff --quiet ignores stat-change only entries' ' |
Nguyễn Thái Ngọc Duy | 0e49649 | 2018-03-24 08:44:31 +0100 | [diff] [blame] | 150 | test-tool chmtime +10 a && |
Nguyễn Thái Ngọc Duy | f34b205 | 2014-01-25 13:46:50 +0700 | [diff] [blame] | 151 | echo modified >>b && |
| 152 | test_expect_code 1 git diff --quiet |
| 153 | ' |
| 154 | |
Junio C Hamano | 12426e1 | 2017-03-01 18:04:44 +0100 | [diff] [blame] | 155 | test_expect_success 'git diff --quiet on a path that need conversion' ' |
| 156 | echo "crlf.txt text=auto" >.gitattributes && |
| 157 | printf "Hello\r\nWorld\r\n" >crlf.txt && |
| 158 | git add .gitattributes crlf.txt && |
| 159 | |
| 160 | printf "Hello\r\nWorld\n" >crlf.txt && |
| 161 | git diff --quiet crlf.txt |
| 162 | ' |
| 163 | |
Alex Riesen | 0c66d6b | 2007-03-14 23:57:23 +0100 | [diff] [blame] | 164 | test_done |