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 && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 260 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 261 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 262 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 263 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 264 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 265 | test_expect_success 'submodule contains untracked content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 266 | echo new > sm1/new-file && |
| 267 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 268 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 269 | Submodule sm1 contains untracked content |
| 270 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 271 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 272 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 273 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 274 | test_expect_success 'submodule contains untracked content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 275 | git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 276 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 277 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 278 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 279 | test_expect_success 'submodule contains untracked content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 280 | git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 281 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 282 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 283 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 284 | test_expect_success 'submodule contains untracked content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 285 | git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 286 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 287 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 288 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 289 | test_expect_success 'submodule contains untracked and modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 290 | echo new > sm1/foo6 && |
| 291 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 292 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 293 | Submodule sm1 contains untracked content |
| 294 | Submodule sm1 contains modified content |
| 295 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 296 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 297 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 298 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 299 | test_expect_success 'submodule contains untracked and modifed content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 300 | echo new > sm1/foo6 && |
| 301 | 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] | 302 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 303 | Submodule sm1 contains modified content |
| 304 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 305 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 306 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 307 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 308 | test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 309 | echo new > sm1/foo6 && |
| 310 | git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 311 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 312 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 313 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 314 | test_expect_success 'submodule contains untracked and modifed content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 315 | echo new > sm1/foo6 && |
| 316 | git diff-index -p --ignore-submodules --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 317 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 318 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 319 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 320 | test_expect_success 'submodule contains modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 321 | rm -f sm1/new-file && |
| 322 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 323 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 324 | Submodule sm1 contains modified content |
| 325 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 326 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 327 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 328 | |
| 329 | (cd sm1; git commit -mchange foo6 >/dev/null) && |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 330 | head8=$(cd sm1; git rev-parse --short --verify HEAD) && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 331 | test_expect_success 'submodule is modified' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 332 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 333 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 334 | Submodule sm1 $head6..$head8: |
| 335 | > change |
| 336 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 337 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 338 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 339 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 340 | test_expect_success 'modified submodule contains untracked content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 341 | echo new > sm1/new-file && |
| 342 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 343 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 344 | Submodule sm1 contains untracked content |
| 345 | Submodule sm1 $head6..$head8: |
| 346 | > change |
| 347 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 348 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 349 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 350 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 351 | test_expect_success 'modified submodule contains untracked content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 352 | 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] | 353 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 354 | Submodule sm1 $head6..$head8: |
| 355 | > change |
| 356 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 357 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 358 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 359 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 360 | test_expect_success 'modified submodule contains untracked content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 361 | 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] | 362 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 363 | Submodule sm1 $head6..$head8: |
| 364 | > change |
| 365 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 366 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 367 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 368 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 369 | test_expect_success 'modified submodule contains untracked content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 370 | git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 371 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 372 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 373 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 374 | test_expect_success 'modified submodule contains untracked and modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 375 | echo modification >> sm1/foo6 && |
| 376 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 377 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 378 | Submodule sm1 contains untracked content |
| 379 | Submodule sm1 contains modified content |
| 380 | Submodule sm1 $head6..$head8: |
| 381 | > change |
| 382 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 383 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 384 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 385 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 386 | test_expect_success 'modified submodule contains untracked and modifed content (untracked ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 387 | echo modification >> sm1/foo6 && |
| 388 | 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] | 389 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 390 | Submodule sm1 contains modified content |
| 391 | Submodule sm1 $head6..$head8: |
| 392 | > change |
| 393 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 394 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 395 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 396 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 397 | test_expect_success 'modified submodule contains untracked and modifed content (dirty ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 398 | echo modification >> sm1/foo6 && |
| 399 | 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] | 400 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 401 | Submodule sm1 $head6..$head8: |
| 402 | > change |
| 403 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 404 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 405 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 406 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 407 | test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 408 | echo modification >> sm1/foo6 && |
| 409 | git diff-index -p --ignore-submodules --submodule=log HEAD >actual && |
Brian Gernhardt | 6ed7dda | 2010-06-25 13:20:48 -0400 | [diff] [blame] | 410 | ! test -s actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 411 | ' |
Jens Lehmann | dd44d41 | 2010-06-08 18:31:51 +0200 | [diff] [blame] | 412 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 413 | test_expect_success 'modified submodule contains modifed content' ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 414 | rm -f sm1/new-file && |
| 415 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 416 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 417 | Submodule sm1 contains modified content |
| 418 | Submodule sm1 $head6..$head8: |
| 419 | > change |
| 420 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 421 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 422 | ' |
Jens Lehmann | 721ceec | 2010-01-24 15:09:00 +0100 | [diff] [blame] | 423 | |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 424 | rm -rf sm1 |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 425 | test_expect_success 'deleted submodule' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 426 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 427 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 428 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 429 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 430 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 431 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 432 | |
Jeff King | 17f2f88 | 2017-06-14 06:58:25 -0400 | [diff] [blame] | 433 | test_expect_success 'create second submodule' ' |
| 434 | test_create_repo sm2 && |
| 435 | head7=$(add_file sm2 foo8 foo9) && |
| 436 | git add sm2 |
| 437 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 438 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 439 | test_expect_success 'multiple submodules' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 440 | git diff-index -p --submodule=log HEAD >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 441 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 442 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 443 | Submodule sm2 0000000...$head7 (new submodule) |
| 444 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 445 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 446 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 447 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 448 | test_expect_success 'path filter' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 449 | git diff-index -p --submodule=log HEAD sm2 >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 450 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 451 | Submodule sm2 0000000...$head7 (new submodule) |
| 452 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 453 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 454 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 455 | |
| 456 | commit_file sm2 |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 457 | test_expect_success 'given commit' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 458 | git diff-index -p --submodule=log HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 459 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 460 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 461 | Submodule sm2 0000000...$head7 (new submodule) |
| 462 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 463 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 464 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 465 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 466 | test_expect_success 'given commit --submodule' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 467 | git diff-index -p --submodule HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 468 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 469 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 470 | Submodule sm2 0000000...$head7 (new submodule) |
| 471 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 472 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 473 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 474 | |
Ramkumar Ramachandra | 20fa538 | 2012-11-30 17:07:34 +0530 | [diff] [blame] | 475 | fullhead7=$(cd sm2; git rev-parse --verify HEAD) |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 476 | |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 477 | test_expect_success 'given commit --submodule=short' ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 478 | git diff-index -p --submodule=short HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 479 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 480 | diff --git a/sm1 b/sm1 |
| 481 | deleted file mode 160000 |
| 482 | index $head6..0000000 |
| 483 | --- a/sm1 |
| 484 | +++ /dev/null |
| 485 | @@ -1 +0,0 @@ |
| 486 | -Subproject commit $fullhead6 |
| 487 | diff --git a/sm2 b/sm2 |
| 488 | new file mode 160000 |
| 489 | index 0000000..$head7 |
| 490 | --- /dev/null |
| 491 | +++ b/sm2 |
| 492 | @@ -0,0 +1 @@ |
| 493 | +Subproject commit $fullhead7 |
| 494 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 495 | test_cmp expected actual |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 496 | ' |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 497 | |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 498 | test_expect_success 'setup .git file for sm2' ' |
| 499 | (cd sm2 && |
| 500 | REAL="$(pwd)/../.real" && |
| 501 | mv .git "$REAL" |
| 502 | echo "gitdir: $REAL" >.git) |
| 503 | ' |
| 504 | |
| 505 | test_expect_success 'diff --submodule with .git file' ' |
| 506 | git diff --submodule HEAD^ >actual && |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 507 | cat >expected <<-EOF && |
Ramkumar Ramachandra | a1549f9 | 2012-11-30 17:07:36 +0530 | [diff] [blame] | 508 | Submodule sm1 $head6...0000000 (submodule deleted) |
| 509 | Submodule sm2 0000000...$head7 (new submodule) |
| 510 | EOF |
Ævar Arnfjörð Bjarmason | f8d186b | 2010-11-14 14:44:16 +0000 | [diff] [blame] | 511 | test_cmp expected actual |
Jens Lehmann | eee49b6 | 2010-04-10 19:01:12 +0200 | [diff] [blame] | 512 | ' |
| 513 | |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 514 | test_expect_success 'diff --submodule with objects referenced by alternates' ' |
| 515 | mkdir sub_alt && |
| 516 | (cd sub_alt && |
| 517 | git init && |
| 518 | echo a >a && |
| 519 | git add a && |
| 520 | git commit -m a |
| 521 | ) && |
| 522 | mkdir super && |
| 523 | (cd super && |
| 524 | git clone -s ../sub_alt sub && |
| 525 | git init && |
| 526 | git add sub && |
| 527 | git commit -m "sub a" |
| 528 | ) && |
| 529 | (cd sub_alt && |
| 530 | sha1_before=$(git rev-parse --short HEAD) |
| 531 | echo b >b && |
| 532 | git add b && |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 533 | git commit -m b && |
| 534 | sha1_after=$(git rev-parse --short HEAD) && |
| 535 | { |
| 536 | echo "Submodule sub $sha1_before..$sha1_after:" && |
| 537 | echo " > b" |
| 538 | } >../expected |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 539 | ) && |
| 540 | (cd super && |
| 541 | (cd sub && |
| 542 | git fetch && |
| 543 | git checkout origin/master |
| 544 | ) && |
| 545 | git diff --submodule > ../actual |
Jeff King | 60687de | 2015-03-20 06:06:44 -0400 | [diff] [blame] | 546 | ) && |
Heiko Voigt | 5e73633 | 2012-05-14 18:24:45 +0200 | [diff] [blame] | 547 | test_cmp expected actual |
| 548 | ' |
| 549 | |
Jens Lehmann | 86140d5 | 2009-10-23 13:25:33 +0200 | [diff] [blame] | 550 | test_done |