Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2009 Jens Lehmann, based on t7401 by Ping Yin |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 4 | # Copyright (c) 2011 Alexey Shumkin (+ non-UTF-8 commit encoding tests) |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 5 | # |
| 6 | |
| 7 | test_description='Support for verbose submodule differences in git diff |
| 8 | |
| 9 | This test tries to verify the sanity of the --submodule option of git diff. |
| 10 | ' |
| 11 | |
| 12 | . ./test-lib.sh |
| 13 | |
Alexey Shumkin | ee3efaf | 2014-05-21 17:20:04 +0400 | [diff] [blame] | 14 | # Tested non-UTF-8 encoding |
| 15 | test_encoding="ISO8859-1" |
| 16 | |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 17 | # String "added" in German (translated with Google Translate), encoded in UTF-8, |
| 18 | # used in sample commit log messages in add_file() function below. |
| 19 | added=$(printf "hinzugef\303\274gt") |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 20 | add_file () { |
Ramkumar Ramachandra | 2934975 | 2012-11-30 17:07:35 +0530 | [diff] [blame] | 21 | ( |
| 22 | cd "$1" && |
| 23 | shift && |
| 24 | for name |
| 25 | do |
| 26 | echo "$name" >"$name" && |
| 27 | git add "$name" && |
| 28 | test_tick && |
Pat Thoyts | e6ce2be | 2013-09-02 15:44:54 +0100 | [diff] [blame] | 29 | # "git commit -m" would break MinGW, as Windows refuse to pass |
| 30 | # $test_encoding encoded parameter to git. |
| 31 | echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding | |
| 32 | git -c "i18n.commitEncoding=$test_encoding" commit -F - |
Ramkumar Ramachandra | 2934975 | 2012-11-30 17:07:35 +0530 | [diff] [blame] | 33 | done >/dev/null && |
| 34 | git rev-parse --short --verify HEAD |
| 35 | ) |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 36 | } |
| 37 | commit_file () { |
| 38 | test_tick && |
| 39 | git commit "$@" -m "Commit $*" >/dev/null |
| 40 | } |
| 41 | |
| 42 | test_create_repo sm1 && |
| 43 | add_file . foo >/dev/null |
| 44 | |
| 45 | head1=$(add_file sm1 foo1 foo2) |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 46 | fullhead1=$(cd sm1; git rev-parse --verify HEAD) |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 47 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 48 | test_expect_success 'added submodule' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 49 | git add sm1 && |
| 50 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 51 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 52 | Submodule sm1 0000000...$head1 (new submodule) |
| 53 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 54 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 55 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 56 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 57 | test_expect_success 'added submodule, set diff.submodule' ' |
Ramkumar Ramachandra | c47ef57 | 2012-11-13 21:12:45 +0530 | [diff] [blame] | 58 | git config diff.submodule log && |
| 59 | git add sm1 && |
| 60 | git diff --cached >actual && |
| 61 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 62 | Submodule sm1 0000000...$head1 (new submodule) |
| 63 | EOF |
Ramkumar Ramachandra | c47ef57 | 2012-11-13 21:12:45 +0530 | [diff] [blame] | 64 | git config --unset diff.submodule && |
| 65 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 66 | ' |
Ramkumar Ramachandra | c47ef57 | 2012-11-13 21:12:45 +0530 | [diff] [blame] | 67 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 68 | test_expect_success '--submodule=short overrides diff.submodule' ' |
Ramkumar Ramachandra | c47ef57 | 2012-11-13 21:12:45 +0530 | [diff] [blame] | 69 | test_config diff.submodule log && |
| 70 | git add sm1 && |
| 71 | git diff --submodule=short --cached >actual && |
| 72 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 73 | diff --git a/sm1 b/sm1 |
| 74 | new file mode 160000 |
| 75 | index 0000000..$head1 |
| 76 | --- /dev/null |
| 77 | +++ b/sm1 |
| 78 | @@ -0,0 +1 @@ |
| 79 | +Subproject commit $fullhead1 |
| 80 | EOF |
Ramkumar Ramachandra | c47ef57 | 2012-11-13 21:12:45 +0530 | [diff] [blame] | 81 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 82 | ' |
Ramkumar Ramachandra | c47ef57 | 2012-11-13 21:12:45 +0530 | [diff] [blame] | 83 | |
Jeff King | d9c552f | 2012-11-13 21:12:46 +0530 | [diff] [blame] | 84 | test_expect_success 'diff.submodule does not affect plumbing' ' |
| 85 | test_config diff.submodule log && |
| 86 | git diff-index -p HEAD >actual && |
| 87 | cat >expected <<-EOF && |
| 88 | diff --git a/sm1 b/sm1 |
| 89 | new file mode 160000 |
Ramkumar Ramachandra | 3b13af9 | 2012-11-26 19:24:28 +0530 | [diff] [blame] | 90 | index 0000000..$head1 |
Jeff King | d9c552f | 2012-11-13 21:12:46 +0530 | [diff] [blame] | 91 | --- /dev/null |
| 92 | +++ b/sm1 |
| 93 | @@ -0,0 +1 @@ |
| 94 | +Subproject commit $fullhead1 |
| 95 | EOF |
| 96 | test_cmp expected actual |
| 97 | ' |
| 98 | |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 99 | commit_file sm1 && |
| 100 | head2=$(add_file sm1 foo3) |
| 101 | |
Alexey Shumkin | ecaee80 | 2013-06-26 14:19:50 +0400 | [diff] [blame] | 102 | test_expect_success 'modified submodule(forward)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 103 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 104 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 105 | Submodule sm1 $head1..$head2: |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 106 | > Add foo3 ($added foo3) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 107 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 108 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 109 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 110 | |
Alexey Shumkin | ecaee80 | 2013-06-26 14:19:50 +0400 | [diff] [blame] | 111 | test_expect_success 'modified submodule(forward)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 112 | git diff --submodule=log >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 113 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 114 | Submodule sm1 $head1..$head2: |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 115 | > Add foo3 ($added foo3) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 116 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 117 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 118 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 119 | |
Alexey Shumkin | ecaee80 | 2013-06-26 14:19:50 +0400 | [diff] [blame] | 120 | test_expect_success 'modified submodule(forward) --submodule' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 121 | git diff --submodule >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 122 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 123 | Submodule sm1 $head1..$head2: |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 124 | > Add foo3 ($added foo3) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 125 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 126 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 127 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 128 | |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 129 | fullhead2=$(cd sm1; git rev-parse --verify HEAD) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 130 | test_expect_success 'modified submodule(forward) --submodule=short' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 131 | git diff --submodule=short >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 132 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 133 | diff --git a/sm1 b/sm1 |
| 134 | index $head1..$head2 160000 |
| 135 | --- a/sm1 |
| 136 | +++ b/sm1 |
| 137 | @@ -1 +1 @@ |
| 138 | -Subproject commit $fullhead1 |
| 139 | +Subproject commit $fullhead2 |
| 140 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 141 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 142 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 143 | |
| 144 | commit_file sm1 && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 145 | head3=$( |
| 146 | cd sm1 && |
| 147 | git reset --hard HEAD~2 >/dev/null && |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 148 | git rev-parse --short --verify HEAD |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 149 | ) |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 150 | |
Alexey Shumkin | ecaee80 | 2013-06-26 14:19:50 +0400 | [diff] [blame] | 151 | test_expect_success 'modified submodule(backward)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 152 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 153 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 154 | Submodule sm1 $head2..$head3 (rewind): |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 155 | < Add foo3 ($added foo3) |
| 156 | < Add foo2 ($added foo2) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 157 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 158 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 159 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 160 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 161 | head4=$(add_file sm1 foo4 foo5) |
Alexey Shumkin | ecaee80 | 2013-06-26 14:19:50 +0400 | [diff] [blame] | 162 | test_expect_success 'modified submodule(backward and forward)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 163 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 164 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 165 | Submodule sm1 $head2...$head4: |
Alexey Shumkin | de6029a | 2013-06-26 14:19:49 +0400 | [diff] [blame] | 166 | > Add foo5 ($added foo5) |
| 167 | > Add foo4 ($added foo4) |
| 168 | < Add foo3 ($added foo3) |
| 169 | < Add foo2 ($added foo2) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 170 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 171 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 172 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 173 | |
| 174 | commit_file sm1 && |
| 175 | mv sm1 sm1-bak && |
| 176 | echo sm1 >sm1 && |
| 177 | head5=$(git hash-object sm1 | cut -c1-7) && |
| 178 | git add sm1 && |
| 179 | rm -f sm1 && |
| 180 | mv sm1-bak sm1 |
| 181 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 182 | test_expect_success 'typechanged submodule(submodule->blob), --cached' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 183 | git diff --submodule=log --cached >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 184 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 185 | Submodule sm1 $head4...0000000 (submodule deleted) |
| 186 | diff --git a/sm1 b/sm1 |
| 187 | new file mode 100644 |
| 188 | index 0000000..$head5 |
| 189 | --- /dev/null |
| 190 | +++ b/sm1 |
| 191 | @@ -0,0 +1 @@ |
| 192 | +sm1 |
| 193 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 194 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 195 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 196 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 197 | test_expect_success 'typechanged submodule(submodule->blob)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 198 | git diff --submodule=log >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 199 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 200 | diff --git a/sm1 b/sm1 |
| 201 | deleted file mode 100644 |
| 202 | index $head5..0000000 |
| 203 | --- a/sm1 |
| 204 | +++ /dev/null |
| 205 | @@ -1 +0,0 @@ |
| 206 | -sm1 |
| 207 | Submodule sm1 0000000...$head4 (new submodule) |
| 208 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 209 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 210 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 211 | |
| 212 | rm -rf sm1 && |
| 213 | git checkout-index sm1 |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 214 | test_expect_success 'typechanged submodule(submodule->blob)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 215 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 216 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 217 | Submodule sm1 $head4...0000000 (submodule deleted) |
| 218 | diff --git a/sm1 b/sm1 |
| 219 | new file mode 100644 |
| 220 | index 0000000..$head5 |
| 221 | --- /dev/null |
| 222 | +++ b/sm1 |
| 223 | @@ -0,0 +1 @@ |
| 224 | +sm1 |
| 225 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 226 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 227 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 228 | |
| 229 | rm -f sm1 && |
| 230 | test_create_repo sm1 && |
| 231 | head6=$(add_file sm1 foo6 foo7) |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 232 | fullhead6=$(cd sm1; git rev-parse --verify HEAD) |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 233 | test_expect_success 'nonexistent commit' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 234 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 235 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 236 | Submodule sm1 $head4...$head6 (commits not present) |
| 237 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 238 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 239 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 240 | |
| 241 | commit_file |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 242 | test_expect_success 'typechanged submodule(blob->submodule)' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 243 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 244 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 245 | diff --git a/sm1 b/sm1 |
| 246 | deleted file mode 100644 |
| 247 | index $head5..0000000 |
| 248 | --- a/sm1 |
| 249 | +++ /dev/null |
| 250 | @@ -1 +0,0 @@ |
| 251 | -sm1 |
| 252 | Submodule sm1 0000000...$head6 (new submodule) |
| 253 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 254 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 255 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 256 | |
| 257 | commit_file sm1 && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 258 | test_expect_success 'submodule is up to date' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 259 | git diff-index -p --submodule=log HEAD >actual && |
SZEDER Gábor | 1c5e94f | 2018-08-19 23:57:25 +0200 | [diff] [blame] | 260 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 261 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 262 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 263 | test_expect_success 'submodule contains untracked content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 264 | echo new > sm1/new-file && |
| 265 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 266 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 267 | Submodule sm1 contains untracked content |
| 268 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 269 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 270 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 271 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 272 | test_expect_success 'submodule contains untracked content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 273 | git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 274 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 275 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 276 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 277 | test_expect_success 'submodule contains untracked content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 278 | git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 279 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 280 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 281 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 282 | test_expect_success 'submodule contains untracked content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 283 | git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 284 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 285 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 286 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 287 | test_expect_success 'submodule contains untracked and modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 288 | echo new > sm1/foo6 && |
| 289 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 290 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 291 | Submodule sm1 contains untracked content |
| 292 | Submodule sm1 contains modified content |
| 293 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 294 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 295 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 296 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 297 | test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 298 | echo new > sm1/foo6 && |
| 299 | git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 300 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 301 | Submodule sm1 contains modified content |
| 302 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 303 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 304 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 305 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 306 | test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 307 | echo new > sm1/foo6 && |
| 308 | git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 309 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 310 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 311 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 312 | test_expect_success 'submodule contains untracked and modifed content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 313 | echo new > sm1/foo6 && |
| 314 | git diff-index -p --ignore-submodules --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 315 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 316 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 317 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 318 | test_expect_success 'submodule contains modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 319 | rm -f sm1/new-file && |
| 320 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 321 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 322 | Submodule sm1 contains modified content |
| 323 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 324 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 325 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 326 | |
| 327 | (cd sm1; git commit -mchange foo6 >/dev/null) && |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 328 | head8=$(cd sm1; git rev-parse --short --verify HEAD) && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 329 | test_expect_success 'submodule is modified' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 330 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 331 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 332 | Submodule sm1 $head6..$head8: |
| 333 | > change |
| 334 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 335 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 336 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 337 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 338 | test_expect_success 'modified submodule contains untracked content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 339 | echo new > sm1/new-file && |
| 340 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 341 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 342 | Submodule sm1 contains untracked content |
| 343 | Submodule sm1 $head6..$head8: |
| 344 | > change |
| 345 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 346 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 347 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 348 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 349 | test_expect_success 'modified submodule contains untracked content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 350 | git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 351 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 352 | Submodule sm1 $head6..$head8: |
| 353 | > change |
| 354 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 355 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 356 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 357 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 358 | test_expect_success 'modified submodule contains untracked content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 359 | git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 360 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 361 | Submodule sm1 $head6..$head8: |
| 362 | > change |
| 363 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 364 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 365 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 366 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 367 | test_expect_success 'modified submodule contains untracked content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 368 | git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 369 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 370 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 371 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 372 | test_expect_success 'modified submodule contains untracked and modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 373 | echo modification >> sm1/foo6 && |
| 374 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 375 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 376 | Submodule sm1 contains untracked content |
| 377 | Submodule sm1 contains modified content |
| 378 | Submodule sm1 $head6..$head8: |
| 379 | > change |
| 380 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 381 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 382 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 383 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 384 | test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 385 | echo modification >> sm1/foo6 && |
| 386 | git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 387 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 388 | Submodule sm1 contains modified content |
| 389 | Submodule sm1 $head6..$head8: |
| 390 | > change |
| 391 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 392 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 393 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 394 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 395 | test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 396 | echo modification >> sm1/foo6 && |
| 397 | git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 398 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 399 | Submodule sm1 $head6..$head8: |
| 400 | > change |
| 401 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 402 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 403 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 404 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 405 | test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 406 | echo modification >> sm1/foo6 && |
| 407 | git diff-index -p --ignore-submodules --submodule=log HEAD >actual && |
SZEDER Gábor | ec10b01 | 2018-08-19 23:57:22 +0200 | [diff] [blame] | 408 | test_must_be_empty actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 409 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 410 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 411 | test_expect_success 'modified submodule contains modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 412 | rm -f sm1/new-file && |
| 413 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 414 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 415 | Submodule sm1 contains modified content |
| 416 | Submodule sm1 $head6..$head8: |
| 417 | > change |
| 418 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 419 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 420 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 421 | |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 422 | rm -rf sm1 |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 423 | test_expect_success 'deleted submodule' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 424 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 425 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 426 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 427 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 428 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 429 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 430 | |
Jeff King | 17f2f88 | 2017-06-14 06:58:25 -0400 | [diff] [blame] | 431 | test_expect_success 'create second submodule' ' |
| 432 | test_create_repo sm2 && |
| 433 | head7=$(add_file sm2 foo8 foo9) && |
| 434 | git add sm2 |
| 435 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 436 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 437 | test_expect_success 'multiple submodules' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 438 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 439 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 440 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 441 | Submodule sm2 0000000...$head7 (new submodule) |
| 442 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 443 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 444 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 445 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 446 | test_expect_success 'path filter' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 447 | git diff-index -p --submodule=log HEAD sm2 >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 448 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 449 | Submodule sm2 0000000...$head7 (new submodule) |
| 450 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 451 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 452 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 453 | |
| 454 | commit_file sm2 |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 455 | test_expect_success 'given commit' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 456 | git diff-index -p --submodule=log HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 457 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 458 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 459 | Submodule sm2 0000000...$head7 (new submodule) |
| 460 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 461 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 462 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 463 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 464 | test_expect_success 'given commit --submodule' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 465 | git diff-index -p --submodule HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 466 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 467 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 468 | Submodule sm2 0000000...$head7 (new submodule) |
| 469 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 470 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 471 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 472 | |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 473 | fullhead7=$(cd sm2; git rev-parse --verify HEAD) |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 474 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 475 | test_expect_success 'given commit --submodule=short' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 476 | git diff-index -p --submodule=short HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 477 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 478 | diff --git a/sm1 b/sm1 |
| 479 | deleted file mode 160000 |
| 480 | index $head6..0000000 |
| 481 | --- a/sm1 |
| 482 | +++ /dev/null |
| 483 | @@ -1 +0,0 @@ |
| 484 | -Subproject commit $fullhead6 |
| 485 | diff --git a/sm2 b/sm2 |
| 486 | new file mode 160000 |
| 487 | index 0000000..$head7 |
| 488 | --- /dev/null |
| 489 | +++ b/sm2 |
| 490 | @@ -0,0 +1 @@ |
| 491 | +Subproject commit $fullhead7 |
| 492 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 493 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 494 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 495 | |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 496 | test_expect_success 'setup .git file for sm2' ' |
| 497 | (cd sm2 && |
| 498 | REAL="$(pwd)/../.real" && |
Eric Sunshine | f957f03 | 2018-07-01 20:24:00 -0400 | [diff] [blame] | 499 | mv .git "$REAL" && |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 500 | echo "gitdir: $REAL" >.git) |
| 501 | ' |
| 502 | |
| 503 | test_expect_success 'diff --submodule with .git file' ' |
| 504 | git diff --submodule HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 505 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 506 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 507 | Submodule sm2 0000000...$head7 (new submodule) |
| 508 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 509 | test_cmp expected actual |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 510 | ' |
| 511 | |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 512 | test_expect_success 'diff --submodule with objects referenced by alternates' ' |
| 513 | mkdir sub_alt && |
| 514 | (cd sub_alt && |
| 515 | git init && |
| 516 | echo a >a && |
| 517 | git add a && |
| 518 | git commit -m a |
| 519 | ) && |
| 520 | mkdir super && |
| 521 | (cd super && |
| 522 | git clone -s ../sub_alt sub && |
| 523 | git init && |
| 524 | git add sub && |
| 525 | git commit -m "sub a" |
| 526 | ) && |
| 527 | (cd sub_alt && |
Eric Sunshine | f957f03 | 2018-07-01 20:24:00 -0400 | [diff] [blame] | 528 | sha1_before=$(git rev-parse --short HEAD) && |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 529 | echo b >b && |
| 530 | git add b && |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 531 | git commit -m b && |
| 532 | sha1_after=$(git rev-parse --short HEAD) && |
| 533 | { |
| 534 | echo "Submodule sub $sha1_before..$sha1_after:" && |
| 535 | echo " > b" |
| 536 | } >../expected |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 537 | ) && |
| 538 | (cd super && |
| 539 | (cd sub && |
| 540 | git fetch && |
| 541 | git checkout origin/master |
| 542 | ) && |
| 543 | git diff --submodule > ../actual |
Jeff King | 60687de | 2015-03-20 06:06:44 -0400 | [diff] [blame] | 544 | ) && |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 545 | test_cmp expected actual |
| 546 | ' |
| 547 | |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 548 | test_done |