Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Johannes E. Schindelin |
| 4 | # |
| 5 | |
Nanako Shiraishi | eaa2a6f | 2008-09-10 06:25:25 +0900 | [diff] [blame] | 6 | test_description='git fast-export' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 7 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 8 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 9 | |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 10 | . ./test-lib.sh |
| 11 | |
| 12 | test_expect_success 'setup' ' |
| 13 | |
Elijah Newren | ebeec7d | 2009-03-25 17:53:23 -0600 | [diff] [blame] | 14 | echo break it > file0 && |
| 15 | git add file0 && |
| 16 | test_tick && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 17 | echo Wohlauf > file && |
| 18 | git add file && |
| 19 | test_tick && |
| 20 | git commit -m initial && |
| 21 | echo die Luft > file && |
| 22 | echo geht frisch > file2 && |
| 23 | git add file file2 && |
| 24 | test_tick && |
| 25 | git commit -m second && |
| 26 | echo und > file2 && |
| 27 | test_tick && |
| 28 | git commit -m third file2 && |
| 29 | test_tick && |
| 30 | git tag rein && |
| 31 | git checkout -b wer HEAD^ && |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 32 | echo lange > file2 && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 33 | test_tick && |
| 34 | git commit -m sitzt file2 && |
| 35 | test_tick && |
| 36 | git tag -a -m valentin muss && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 37 | git merge -s ours main |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 38 | |
| 39 | ' |
| 40 | |
| 41 | test_expect_success 'fast-export | fast-import' ' |
| 42 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 43 | MAIN=$(git rev-parse --verify main) && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 44 | REIN=$(git rev-parse --verify rein) && |
| 45 | WER=$(git rev-parse --verify wer) && |
| 46 | MUSS=$(git rev-parse --verify muss) && |
| 47 | mkdir new && |
| 48 | git --git-dir=new/.git init && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 49 | git fast-export --all >actual && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 50 | (cd new && |
| 51 | git fast-import && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 52 | test $MAIN = $(git rev-parse --verify refs/heads/main) && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 53 | test $REIN = $(git rev-parse --verify refs/tags/rein) && |
| 54 | test $WER = $(git rev-parse --verify refs/heads/wer) && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 55 | test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 56 | |
| 57 | ' |
| 58 | |
Elijah Newren | af2abd8 | 2019-09-24 18:39:58 -0700 | [diff] [blame] | 59 | test_expect_success 'fast-export ^muss^{commit} muss' ' |
| 60 | git fast-export --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && |
| 61 | cat >expected <<-EOF && |
| 62 | tag muss |
| 63 | from $(git rev-parse --verify muss^{commit}) |
| 64 | $(git cat-file tag muss | grep tagger) |
| 65 | data 9 |
| 66 | valentin |
| 67 | |
| 68 | EOF |
| 69 | test_cmp expected actual |
| 70 | ' |
| 71 | |
Elijah Newren | a1638cf | 2019-10-03 13:27:07 -0700 | [diff] [blame] | 72 | test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' ' |
| 73 | git fast-export --mark-tags --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && |
| 74 | cat >expected <<-EOF && |
| 75 | tag muss |
| 76 | mark :1 |
| 77 | from $(git rev-parse --verify muss^{commit}) |
| 78 | $(git cat-file tag muss | grep tagger) |
| 79 | data 9 |
| 80 | valentin |
| 81 | |
| 82 | EOF |
| 83 | test_cmp expected actual |
| 84 | ' |
| 85 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 86 | test_expect_success 'fast-export main~2..main' ' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 87 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 88 | git fast-export main~2..main >actual && |
| 89 | sed "s/main/partial/" actual | |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 90 | (cd new && |
| 91 | git fast-import && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 92 | test $MAIN != $(git rev-parse --verify refs/heads/partial) && |
| 93 | git diff --exit-code main partial && |
| 94 | git diff --exit-code main^ partial^ && |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 95 | test_must_fail git rev-parse partial~2) |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 96 | |
| 97 | ' |
| 98 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 99 | test_expect_success 'fast-export --reference-excluded-parents main~2..main' ' |
Elijah Newren | 530ca19 | 2018-11-15 23:59:54 -0800 | [diff] [blame] | 100 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 101 | git fast-export --reference-excluded-parents main~2..main >actual && |
| 102 | grep commit.refs/heads/main actual >commit-count && |
Elijah Newren | 530ca19 | 2018-11-15 23:59:54 -0800 | [diff] [blame] | 103 | test_line_count = 2 commit-count && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 104 | sed "s/main/rewrite/" actual | |
Elijah Newren | 530ca19 | 2018-11-15 23:59:54 -0800 | [diff] [blame] | 105 | (cd new && |
| 106 | git fast-import && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 107 | test $MAIN = $(git rev-parse --verify refs/heads/rewrite)) |
Elijah Newren | 530ca19 | 2018-11-15 23:59:54 -0800 | [diff] [blame] | 108 | ' |
| 109 | |
Elijah Newren | a965bb3 | 2018-11-15 23:59:56 -0800 | [diff] [blame] | 110 | test_expect_success 'fast-export --show-original-ids' ' |
| 111 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 112 | git fast-export --show-original-ids main >output && |
Elijah Newren | a965bb3 | 2018-11-15 23:59:56 -0800 | [diff] [blame] | 113 | grep ^original-oid output| sed -e s/^original-oid.// | sort >actual && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 114 | git rev-list --objects main muss >objects-and-names && |
Elijah Newren | a965bb3 | 2018-11-15 23:59:56 -0800 | [diff] [blame] | 115 | awk "{print \$1}" objects-and-names | sort >commits-trees-blobs && |
| 116 | comm -23 actual commits-trees-blobs >unfound && |
| 117 | test_must_be_empty unfound |
| 118 | ' |
| 119 | |
| 120 | test_expect_success 'fast-export --show-original-ids | git fast-import' ' |
| 121 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 122 | git fast-export --show-original-ids main muss | git fast-import --quiet && |
| 123 | test $MAIN = $(git rev-parse --verify refs/heads/main) && |
Elijah Newren | a965bb3 | 2018-11-15 23:59:56 -0800 | [diff] [blame] | 124 | test $MUSS = $(git rev-parse --verify refs/tags/muss) |
| 125 | ' |
| 126 | |
Elijah Newren | e80001f | 2019-05-13 21:31:02 -0700 | [diff] [blame] | 127 | test_expect_success 'reencoding iso-8859-7' ' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 128 | |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 129 | test_when_finished "git reset --hard HEAD~1" && |
| 130 | test_config i18n.commitencoding iso-8859-7 && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 131 | test_tick && |
| 132 | echo rosten >file && |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 133 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && |
Elijah Newren | e80001f | 2019-05-13 21:31:02 -0700 | [diff] [blame] | 134 | git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 135 | sed "s/wer/i18n/" iso-8859-7.fi | |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 136 | (cd new && |
| 137 | git fast-import && |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 138 | # The commit object, if not re-encoded, would be 200 bytes plus hash. |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 139 | # Removing the "encoding iso-8859-7\n" header drops 20 bytes. |
| 140 | # Re-encoding the Pi character from \xF0 (\360) in iso-8859-7 |
| 141 | # to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for |
| 142 | # the expected size. |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 143 | test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" && |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 144 | # ...and for the expected translation of bytes. |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 145 | git cat-file commit i18n >actual && |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 146 | grep $(printf "\317\200") actual && |
| 147 | # Also make sure the commit does not have the "encoding" header |
| 148 | ! grep ^encoding actual) |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 149 | ' |
Elijah Newren | 32615ce | 2019-05-13 21:30:58 -0700 | [diff] [blame] | 150 | |
Elijah Newren | e80001f | 2019-05-13 21:31:02 -0700 | [diff] [blame] | 151 | test_expect_success 'aborting on iso-8859-7' ' |
| 152 | |
| 153 | test_when_finished "git reset --hard HEAD~1" && |
| 154 | test_config i18n.commitencoding iso-8859-7 && |
| 155 | echo rosten >file && |
| 156 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && |
| 157 | test_must_fail git fast-export --reencode=abort wer^..wer >iso-8859-7.fi |
| 158 | ' |
| 159 | |
| 160 | test_expect_success 'preserving iso-8859-7' ' |
| 161 | |
| 162 | test_when_finished "git reset --hard HEAD~1" && |
| 163 | test_config i18n.commitencoding iso-8859-7 && |
| 164 | echo rosten >file && |
| 165 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && |
| 166 | git fast-export --reencode=no wer^..wer >iso-8859-7.fi && |
| 167 | sed "s/wer/i18n-no-recoding/" iso-8859-7.fi | |
| 168 | (cd new && |
| 169 | git fast-import && |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 170 | # The commit object, if not re-encoded, is 200 bytes plus hash. |
Elijah Newren | e80001f | 2019-05-13 21:31:02 -0700 | [diff] [blame] | 171 | # Removing the "encoding iso-8859-7\n" header would drops 20 |
| 172 | # bytes. Re-encoding the Pi character from \xF0 (\360) in |
| 173 | # iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte. |
| 174 | # Check for the expected size... |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 175 | test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" && |
Elijah Newren | e80001f | 2019-05-13 21:31:02 -0700 | [diff] [blame] | 176 | # ...as well as the expected byte. |
| 177 | git cat-file commit i18n-no-recoding >actual && |
| 178 | grep $(printf "\360") actual && |
| 179 | # Also make sure the commit has the "encoding" header |
| 180 | grep ^encoding actual) |
| 181 | ' |
| 182 | |
Elijah Newren | ccbfc96 | 2019-05-13 21:31:00 -0700 | [diff] [blame] | 183 | test_expect_success 'encoding preserved if reencoding fails' ' |
| 184 | |
| 185 | test_when_finished "git reset --hard HEAD~1" && |
| 186 | test_config i18n.commitencoding iso-8859-7 && |
| 187 | echo rosten >file && |
| 188 | git commit -s -F "$TEST_DIRECTORY/t9350/broken-iso-8859-7-commit-message.txt" file && |
Elijah Newren | e80001f | 2019-05-13 21:31:02 -0700 | [diff] [blame] | 189 | git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && |
Elijah Newren | ccbfc96 | 2019-05-13 21:31:00 -0700 | [diff] [blame] | 190 | sed "s/wer/i18n-invalid/" iso-8859-7.fi | |
| 191 | (cd new && |
| 192 | git fast-import && |
| 193 | git cat-file commit i18n-invalid >actual && |
| 194 | # Make sure the commit still has the encoding header |
| 195 | grep ^encoding actual && |
| 196 | # Verify that the commit has the expected size; i.e. |
| 197 | # that no bytes were re-encoded to a different encoding. |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 198 | test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" && |
Elijah Newren | ccbfc96 | 2019-05-13 21:31:00 -0700 | [diff] [blame] | 199 | # ...and check for the original special bytes |
| 200 | grep $(printf "\360") actual && |
| 201 | grep $(printf "\377") actual) |
| 202 | ' |
| 203 | |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 204 | test_expect_success 'import/export-marks' ' |
| 205 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 206 | git checkout -b marks main && |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 207 | git fast-export --export-marks=tmp-marks HEAD && |
| 208 | test -s tmp-marks && |
Stefano Lattarini | 3fb0459 | 2012-04-11 13:24:01 +0200 | [diff] [blame] | 209 | test_line_count = 3 tmp-marks && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 210 | git fast-export --import-marks=tmp-marks \ |
| 211 | --export-marks=tmp-marks HEAD >actual && |
| 212 | test $(grep ^commit actual | wc -l) -eq 0 && |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 213 | echo change > file && |
| 214 | git commit -m "last commit" file && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 215 | git fast-export --import-marks=tmp-marks \ |
| 216 | --export-marks=tmp-marks HEAD >actual && |
| 217 | test $(grep ^commit\ actual | wc -l) -eq 1 && |
Stefano Lattarini | 3fb0459 | 2012-04-11 13:24:01 +0200 | [diff] [blame] | 218 | test_line_count = 4 tmp-marks |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 219 | |
| 220 | ' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 221 | |
| 222 | cat > signed-tag-import << EOF |
| 223 | tag sign-your-name |
| 224 | from $(git rev-parse HEAD) |
| 225 | tagger C O Mitter <committer@example.com> 1112911993 -0700 |
| 226 | data 210 |
| 227 | A message for a sign |
| 228 | -----BEGIN PGP SIGNATURE----- |
| 229 | Version: GnuPG v1.4.5 (GNU/Linux) |
| 230 | |
| 231 | fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign |
| 232 | aturefakedsignaturefake= |
| 233 | =/59v |
| 234 | -----END PGP SIGNATURE----- |
| 235 | EOF |
| 236 | |
| 237 | test_expect_success 'set up faked signed tag' ' |
| 238 | |
| 239 | cat signed-tag-import | git fast-import |
| 240 | |
| 241 | ' |
| 242 | |
| 243 | test_expect_success 'signed-tags=abort' ' |
| 244 | |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 245 | test_must_fail git fast-export --signed-tags=abort sign-your-name |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 246 | |
| 247 | ' |
| 248 | |
Johannes Schindelin | ee4bc37 | 2007-12-03 22:44:39 +0000 | [diff] [blame] | 249 | test_expect_success 'signed-tags=verbatim' ' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 250 | |
Johannes Schindelin | ee4bc37 | 2007-12-03 22:44:39 +0000 | [diff] [blame] | 251 | git fast-export --signed-tags=verbatim sign-your-name > output && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 252 | grep PGP output |
| 253 | |
| 254 | ' |
| 255 | |
| 256 | test_expect_success 'signed-tags=strip' ' |
| 257 | |
| 258 | git fast-export --signed-tags=strip sign-your-name > output && |
| 259 | ! grep PGP output |
| 260 | |
| 261 | ' |
| 262 | |
John Keeping | cd16c59 | 2013-04-14 11:57:06 +0100 | [diff] [blame] | 263 | test_expect_success 'signed-tags=warn-strip' ' |
| 264 | git fast-export --signed-tags=warn-strip sign-your-name >output 2>err && |
| 265 | ! grep PGP output && |
| 266 | test -s err |
| 267 | ' |
| 268 | |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 269 | test_expect_success 'setup submodule' ' |
| 270 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 271 | git checkout -f main && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 272 | mkdir sub && |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 273 | ( |
| 274 | cd sub && |
| 275 | git init && |
| 276 | echo test file > file && |
| 277 | git add file && |
| 278 | git commit -m sub_initial |
| 279 | ) && |
Elia Pinto | c7b793a | 2016-01-12 11:49:36 +0000 | [diff] [blame] | 280 | git submodule add "$(pwd)/sub" sub && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 281 | git commit -m initial && |
| 282 | test_tick && |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 283 | ( |
| 284 | cd sub && |
| 285 | echo more data >> file && |
| 286 | git add file && |
| 287 | git commit -m sub_second |
| 288 | ) && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 289 | git add sub && |
| 290 | git commit -m second |
| 291 | |
| 292 | ' |
| 293 | |
| 294 | test_expect_success 'submodule fast-export | fast-import' ' |
| 295 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 296 | SUBENT1=$(git ls-tree main^ sub) && |
| 297 | SUBENT2=$(git ls-tree main sub) && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 298 | rm -rf new && |
| 299 | mkdir new && |
| 300 | git --git-dir=new/.git init && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 301 | git fast-export --signed-tags=strip --all >actual && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 302 | (cd new && |
| 303 | git fast-import && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 304 | test "$SUBENT1" = "$(git ls-tree refs/heads/main^ sub)" && |
| 305 | test "$SUBENT2" = "$(git ls-tree refs/heads/main sub)" && |
| 306 | git checkout main && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 307 | git submodule init && |
| 308 | git submodule update && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 309 | cmp sub/file ../sub/file) <actual |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 310 | |
| 311 | ' |
| 312 | |
Junio C Hamano | 91e80b9 | 2009-02-18 11:17:27 -0800 | [diff] [blame] | 313 | GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME |
| 314 | GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME |
Alexander Gavrilov | ae7c5dc | 2008-07-27 00:52:54 +0400 | [diff] [blame] | 315 | |
| 316 | test_expect_success 'setup copies' ' |
| 317 | |
Alexander Gavrilov | ae7c5dc | 2008-07-27 00:52:54 +0400 | [diff] [blame] | 318 | git checkout -b copy rein && |
| 319 | git mv file file3 && |
| 320 | git commit -m move1 && |
| 321 | test_tick && |
| 322 | cp file2 file4 && |
| 323 | git add file4 && |
| 324 | git mv file2 file5 && |
| 325 | git commit -m copy1 && |
| 326 | test_tick && |
| 327 | cp file3 file6 && |
| 328 | git add file6 && |
| 329 | git commit -m copy2 && |
| 330 | test_tick && |
| 331 | echo more text >> file6 && |
| 332 | echo even more text >> file6 && |
| 333 | git add file6 && |
| 334 | git commit -m modify && |
| 335 | test_tick && |
| 336 | cp file6 file7 && |
| 337 | echo test >> file7 && |
| 338 | git add file7 && |
| 339 | git commit -m copy_modify |
| 340 | |
| 341 | ' |
| 342 | |
| 343 | test_expect_success 'fast-export -C -C | fast-import' ' |
| 344 | |
| 345 | ENTRY=$(git rev-parse --verify copy) && |
| 346 | rm -rf new && |
| 347 | mkdir new && |
| 348 | git --git-dir=new/.git init && |
| 349 | git fast-export -C -C --signed-tags=strip --all > output && |
Jonathan Tan | b3e8ca8 | 2017-09-20 16:55:02 -0700 | [diff] [blame] | 350 | grep "^C file2 file4\$" output && |
Alexander Gavrilov | ae7c5dc | 2008-07-27 00:52:54 +0400 | [diff] [blame] | 351 | cat output | |
| 352 | (cd new && |
| 353 | git fast-import && |
| 354 | test $ENTRY = $(git rev-parse --verify refs/heads/copy)) |
| 355 | |
| 356 | ' |
| 357 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 358 | test_expect_success 'fast-export | fast-import when main is tagged' ' |
Miklos Vajna | 283b953 | 2008-11-22 19:22:48 +0100 | [diff] [blame] | 359 | |
| 360 | git tag -m msg last && |
| 361 | git fast-export -C -C --signed-tags=strip --all > output && |
| 362 | test $(grep -c "^tag " output) = 3 |
| 363 | |
| 364 | ' |
| 365 | |
Johannes Schindelin | 4e46a8d | 2008-12-20 01:00:27 +0100 | [diff] [blame] | 366 | cat > tag-content << EOF |
| 367 | object $(git rev-parse HEAD) |
| 368 | type commit |
| 369 | tag rosten |
| 370 | EOF |
| 371 | |
| 372 | test_expect_success 'cope with tagger-less tags' ' |
| 373 | |
| 374 | TAG=$(git hash-object -t tag -w tag-content) && |
| 375 | git update-ref refs/tags/sonnenschein $TAG && |
| 376 | git fast-export -C -C --signed-tags=strip --all > output && |
| 377 | test $(grep -c "^tag " output) = 4 && |
| 378 | ! grep "Unspecified Tagger" output && |
| 379 | git fast-export -C -C --signed-tags=strip --all \ |
| 380 | --fake-missing-tagger > output && |
| 381 | test $(grep -c "^tag " output) = 4 && |
| 382 | grep "Unspecified Tagger" output |
| 383 | |
| 384 | ' |
| 385 | |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 386 | test_expect_success 'setup for limiting exports by PATH' ' |
| 387 | mkdir limit-by-paths && |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 388 | ( |
| 389 | cd limit-by-paths && |
| 390 | git init && |
| 391 | echo hi > there && |
| 392 | git add there && |
| 393 | git commit -m "First file" && |
| 394 | echo foo > bar && |
| 395 | git add bar && |
| 396 | git commit -m "Second file" && |
| 397 | git tag -a -m msg mytag && |
| 398 | echo morefoo >> bar && |
| 399 | git add bar && |
| 400 | git commit -m "Change to second file" |
| 401 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 402 | ' |
| 403 | |
| 404 | cat > limit-by-paths/expected << EOF |
| 405 | blob |
| 406 | mark :1 |
| 407 | data 3 |
| 408 | hi |
| 409 | |
| 410 | reset refs/tags/mytag |
| 411 | commit refs/tags/mytag |
| 412 | mark :2 |
| 413 | author A U Thor <author@example.com> 1112912713 -0700 |
| 414 | committer C O Mitter <committer@example.com> 1112912713 -0700 |
| 415 | data 11 |
| 416 | First file |
| 417 | M 100644 :1 there |
| 418 | |
| 419 | EOF |
| 420 | |
| 421 | test_expect_success 'dropping tag of filtered out object' ' |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 422 | ( |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 423 | cd limit-by-paths && |
| 424 | git fast-export --tag-of-filtered-object=drop mytag -- there > output && |
Felipe Contreras | 9ff10fc | 2012-11-28 23:11:09 +0100 | [diff] [blame] | 425 | test_cmp expected output |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 426 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 427 | ' |
| 428 | |
| 429 | cat >> limit-by-paths/expected << EOF |
| 430 | tag mytag |
| 431 | from :2 |
| 432 | tagger C O Mitter <committer@example.com> 1112912713 -0700 |
| 433 | data 4 |
| 434 | msg |
| 435 | |
| 436 | EOF |
| 437 | |
| 438 | test_expect_success 'rewriting tag of filtered out object' ' |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 439 | ( |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 440 | cd limit-by-paths && |
| 441 | git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && |
Felipe Contreras | 9ff10fc | 2012-11-28 23:11:09 +0100 | [diff] [blame] | 442 | test_cmp expected output |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 443 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 444 | ' |
| 445 | |
Elijah Newren | 1f30c90 | 2018-11-15 23:59:50 -0800 | [diff] [blame] | 446 | test_expect_success 'rewrite tag predating pathspecs to nothing' ' |
| 447 | test_create_repo rewrite_tag_predating_pathspecs && |
| 448 | ( |
| 449 | cd rewrite_tag_predating_pathspecs && |
| 450 | |
| 451 | test_commit initial && |
| 452 | |
| 453 | git tag -a -m "Some old tag" v0.0.0.0.0.0.1 && |
| 454 | |
| 455 | test_commit bar && |
| 456 | |
| 457 | git fast-export --tag-of-filtered-object=rewrite --all -- bar.t >output && |
| 458 | grep from.$ZERO_OID output |
| 459 | ) |
| 460 | ' |
| 461 | |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 462 | cat > limit-by-paths/expected << EOF |
| 463 | blob |
| 464 | mark :1 |
| 465 | data 4 |
| 466 | foo |
| 467 | |
| 468 | blob |
| 469 | mark :2 |
| 470 | data 3 |
| 471 | hi |
| 472 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 473 | reset refs/heads/main |
| 474 | commit refs/heads/main |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 475 | mark :3 |
| 476 | author A U Thor <author@example.com> 1112912713 -0700 |
| 477 | committer C O Mitter <committer@example.com> 1112912713 -0700 |
| 478 | data 12 |
| 479 | Second file |
| 480 | M 100644 :1 bar |
| 481 | M 100644 :2 there |
| 482 | |
| 483 | EOF |
| 484 | |
| 485 | test_expect_failure 'no exact-ref revisions included' ' |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 486 | ( |
| 487 | cd limit-by-paths && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 488 | git fast-export main~2..main~1 > output && |
Felipe Contreras | 9ff10fc | 2012-11-28 23:11:09 +0100 | [diff] [blame] | 489 | test_cmp expected output |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 490 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 491 | ' |
| 492 | |
Elijah Newren | 4087a02 | 2010-07-17 11:00:50 -0600 | [diff] [blame] | 493 | test_expect_success 'path limiting with import-marks does not lose unmodified files' ' |
| 494 | git checkout -b simple marks~2 && |
| 495 | git fast-export --export-marks=marks simple -- file > /dev/null && |
| 496 | echo more content >> file && |
| 497 | test_tick && |
| 498 | git commit -mnext file && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 499 | git fast-export --import-marks=marks simple -- file file0 >actual && |
| 500 | grep file0 actual |
Elijah Newren | 4087a02 | 2010-07-17 11:00:50 -0600 | [diff] [blame] | 501 | ' |
| 502 | |
Elijah Newren | cd13762 | 2018-11-15 23:59:52 -0800 | [diff] [blame] | 503 | test_expect_success 'avoid corrupt stream with non-existent mark' ' |
| 504 | test_create_repo avoid_non_existent_mark && |
| 505 | ( |
| 506 | cd avoid_non_existent_mark && |
| 507 | |
| 508 | test_commit important-path && |
| 509 | |
| 510 | test_commit ignored && |
| 511 | |
| 512 | git branch A && |
| 513 | git branch B && |
| 514 | |
| 515 | echo foo >>important-path.t && |
| 516 | git add important-path.t && |
| 517 | test_commit more changes && |
| 518 | |
| 519 | git fast-export --all -- important-path.t | git fast-import --force |
| 520 | ) |
| 521 | ' |
| 522 | |
Elijah Newren | 7f40ab0 | 2010-07-17 11:00:51 -0600 | [diff] [blame] | 523 | test_expect_success 'full-tree re-shows unmodified files' ' |
| 524 | git checkout -f simple && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 525 | git fast-export --full-tree simple >actual && |
| 526 | test $(grep -c file0 actual) -eq 3 |
Elijah Newren | 7f40ab0 | 2010-07-17 11:00:51 -0600 | [diff] [blame] | 527 | ' |
| 528 | |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 529 | test_expect_success 'set-up a few more tags for tag export tests' ' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 530 | git checkout -f main && |
Elia Pinto | c7b793a | 2016-01-12 11:49:36 +0000 | [diff] [blame] | 531 | HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") && |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 532 | git tag tree_tag -m "tagging a tree" $HEAD_TREE && |
| 533 | git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && |
| 534 | git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && |
| 535 | git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj |
| 536 | ' |
| 537 | |
Elijah Newren | 02c48cd | 2009-06-25 22:48:28 -0600 | [diff] [blame] | 538 | test_expect_success 'tree_tag' ' |
| 539 | mkdir result && |
| 540 | (cd result && git init) && |
| 541 | git fast-export tree_tag > fe-stream && |
| 542 | (cd result && git fast-import < ../fe-stream) |
| 543 | ' |
| 544 | |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 545 | # NEEDSWORK: not just check return status, but validate the output |
Elijah Newren | 8d7d33c | 2019-10-03 13:27:08 -0700 | [diff] [blame] | 546 | # Note that these tests DO NOTHING other than print a warning that |
Elijah Newren | 7a40cf1 | 2019-11-05 17:07:24 +0000 | [diff] [blame] | 547 | # they are omitting the one tag we asked them to export (because the |
Elijah Newren | 8d7d33c | 2019-10-03 13:27:08 -0700 | [diff] [blame] | 548 | # tags resolve to a tree). They exist just to make sure we do not |
| 549 | # abort but instead just warn. |
Erik Faye-Lund | c0582c5 | 2009-03-23 12:53:08 +0000 | [diff] [blame] | 550 | test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' |
Erik Faye-Lund | 1982467 | 2009-03-23 12:53:09 +0000 | [diff] [blame] | 551 | test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' |
| 552 | test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 553 | |
Elijah Newren | 8d7d33c | 2019-10-03 13:27:08 -0700 | [diff] [blame] | 554 | test_expect_success 'handling tags of blobs' ' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 555 | git tag -a -m "Tag of a blob" blobtag $(git rev-parse main:file) && |
Elijah Newren | 8d7d33c | 2019-10-03 13:27:08 -0700 | [diff] [blame] | 556 | git fast-export blobtag >actual && |
| 557 | cat >expect <<-EOF && |
| 558 | blob |
| 559 | mark :1 |
| 560 | data 9 |
| 561 | die Luft |
| 562 | |
| 563 | tag blobtag |
| 564 | from :1 |
| 565 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 566 | data 14 |
| 567 | Tag of a blob |
| 568 | |
| 569 | EOF |
| 570 | test_cmp expect actual |
| 571 | ' |
| 572 | |
Elijah Newren | 941790d | 2019-10-03 13:27:09 -0700 | [diff] [blame] | 573 | test_expect_success 'handling nested tags' ' |
Elijah Newren | 8d7d33c | 2019-10-03 13:27:08 -0700 | [diff] [blame] | 574 | git tag -a -m "This is a nested tag" nested muss && |
| 575 | git fast-export --mark-tags nested >output && |
| 576 | grep "^from $ZERO_OID$" output && |
| 577 | grep "^tag nested$" output >tag_lines && |
| 578 | test_line_count = 2 tag_lines |
| 579 | ' |
| 580 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 581 | test_expect_success 'directory becomes symlink' ' |
Elijah Newren | f15652d | 2010-07-09 07:10:51 -0600 | [diff] [blame] | 582 | git init dirtosymlink && |
| 583 | git init result && |
| 584 | ( |
| 585 | cd dirtosymlink && |
| 586 | mkdir foo && |
| 587 | mkdir bar && |
| 588 | echo hello > foo/world && |
| 589 | echo hello > bar/world && |
| 590 | git add foo/world bar/world && |
| 591 | git commit -q -mone && |
| 592 | git rm -r foo && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 593 | test_ln_s_add bar foo && |
Elijah Newren | f15652d | 2010-07-09 07:10:51 -0600 | [diff] [blame] | 594 | git commit -q -mtwo |
| 595 | ) && |
| 596 | ( |
| 597 | cd dirtosymlink && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 598 | git fast-export main -- foo | |
Elijah Newren | f15652d | 2010-07-09 07:10:51 -0600 | [diff] [blame] | 599 | (cd ../result && git fast-import --quiet) |
| 600 | ) && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 601 | (cd result && git show main:foo) |
Elijah Newren | f15652d | 2010-07-09 07:10:51 -0600 | [diff] [blame] | 602 | ' |
| 603 | |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 604 | test_expect_success 'fast-export quotes pathnames' ' |
| 605 | git init crazy-paths && |
Johannes Schindelin | e1d911d | 2019-09-12 14:54:05 +0200 | [diff] [blame] | 606 | test_config -C crazy-paths core.protectNTFS false && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 607 | (cd crazy-paths && |
Elia Pinto | c7b793a | 2016-01-12 11:49:36 +0000 | [diff] [blame] | 608 | blob=$(echo foo | git hash-object -w --stdin) && |
Johannes Schindelin | 35edce2 | 2019-09-09 15:43:35 +0200 | [diff] [blame] | 609 | git -c core.protectNTFS=false update-index --add \ |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 610 | --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \ |
| 611 | --cacheinfo 100644 $blob "path with \"quote\"" \ |
| 612 | --cacheinfo 100644 $blob "path with \\backslash" \ |
| 613 | --cacheinfo 100644 $blob "path with space" && |
| 614 | git commit -m addition && |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 615 | git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 616 | git read-tree --empty && |
| 617 | git update-index -z --index-info <index && |
| 618 | git commit -m rename && |
| 619 | git read-tree --empty && |
| 620 | git commit -m deletion && |
Jay Soffian | ff59f6d | 2012-06-27 17:58:01 -0400 | [diff] [blame] | 621 | git fast-export -M HEAD >export.out && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 622 | git rev-list HEAD >expect && |
| 623 | git init result && |
| 624 | cd result && |
| 625 | git fast-import <../export.out && |
| 626 | git rev-list HEAD >actual && |
| 627 | test_cmp ../expect actual |
| 628 | ) |
| 629 | ' |
| 630 | |
Felipe Contreras | 5d3698f | 2012-11-24 04:17:01 +0100 | [diff] [blame] | 631 | test_expect_success 'test bidirectionality' ' |
Felipe Contreras | 5d3698f | 2012-11-24 04:17:01 +0100 | [diff] [blame] | 632 | git init marks-test && |
Elijah Newren | 208d692 | 2019-10-03 13:27:06 -0700 | [diff] [blame] | 633 | git fast-export --export-marks=marks-cur --import-marks-if-exists=marks-cur --branches | \ |
| 634 | git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks-if-exists=marks-new && |
Felipe Contreras | 5d3698f | 2012-11-24 04:17:01 +0100 | [diff] [blame] | 635 | (cd marks-test && |
| 636 | git reset --hard && |
| 637 | echo Wohlauf > file && |
| 638 | git commit -a -m "back in time") && |
Elijah Newren | 208d692 | 2019-10-03 13:27:06 -0700 | [diff] [blame] | 639 | git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks-if-exists=marks-new --branches | \ |
| 640 | git fast-import --export-marks=marks-cur --import-marks-if-exists=marks-cur |
Felipe Contreras | 5d3698f | 2012-11-24 04:17:01 +0100 | [diff] [blame] | 641 | ' |
| 642 | |
Felipe Contreras | 49266e8 | 2012-11-28 23:23:59 +0100 | [diff] [blame] | 643 | cat > expected << EOF |
| 644 | blob |
| 645 | mark :13 |
| 646 | data 5 |
| 647 | bump |
| 648 | |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 649 | commit refs/heads/main |
Felipe Contreras | 49266e8 | 2012-11-28 23:23:59 +0100 | [diff] [blame] | 650 | mark :14 |
| 651 | author A U Thor <author@example.com> 1112912773 -0700 |
| 652 | committer C O Mitter <committer@example.com> 1112912773 -0700 |
| 653 | data 5 |
| 654 | bump |
| 655 | from :12 |
| 656 | M 100644 :13 file |
| 657 | |
| 658 | EOF |
| 659 | |
| 660 | test_expect_success 'avoid uninteresting refs' ' |
| 661 | > tmp-marks && |
| 662 | git fast-export --import-marks=tmp-marks \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 663 | --export-marks=tmp-marks main > /dev/null && |
Felipe Contreras | 49266e8 | 2012-11-28 23:23:59 +0100 | [diff] [blame] | 664 | git tag v1.0 && |
| 665 | git branch uninteresting && |
| 666 | echo bump > file && |
| 667 | git commit -a -m bump && |
| 668 | git fast-export --import-marks=tmp-marks \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 669 | --export-marks=tmp-marks ^uninteresting ^v1.0 main > actual && |
Felipe Contreras | 49266e8 | 2012-11-28 23:23:59 +0100 | [diff] [blame] | 670 | test_cmp expected actual |
| 671 | ' |
| 672 | |
Felipe Contreras | f28e7c9 | 2012-11-28 23:24:00 +0100 | [diff] [blame] | 673 | cat > expected << EOF |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 674 | reset refs/heads/main |
Felipe Contreras | f28e7c9 | 2012-11-28 23:24:00 +0100 | [diff] [blame] | 675 | from :14 |
| 676 | |
| 677 | EOF |
| 678 | |
| 679 | test_expect_success 'refs are updated even if no commits need to be exported' ' |
| 680 | > tmp-marks && |
| 681 | git fast-export --import-marks=tmp-marks \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 682 | --export-marks=tmp-marks main > /dev/null && |
Felipe Contreras | f28e7c9 | 2012-11-28 23:24:00 +0100 | [diff] [blame] | 683 | git fast-export --import-marks=tmp-marks \ |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 684 | --export-marks=tmp-marks main > actual && |
Felipe Contreras | f28e7c9 | 2012-11-28 23:24:00 +0100 | [diff] [blame] | 685 | test_cmp expected actual |
| 686 | ' |
| 687 | |
Felipe Contreras | 03e9010 | 2014-04-20 13:59:24 -0500 | [diff] [blame] | 688 | test_expect_success 'use refspec' ' |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 689 | git fast-export --refspec refs/heads/main:refs/heads/foobar main >actual2 && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 690 | grep "^commit " actual2 | sort | uniq >actual && |
Felipe Contreras | 03e9010 | 2014-04-20 13:59:24 -0500 | [diff] [blame] | 691 | echo "commit refs/heads/foobar" > expected && |
| 692 | test_cmp expected actual |
| 693 | ' |
| 694 | |
Elijah Newren | fdf31b6 | 2018-11-15 23:59:53 -0800 | [diff] [blame] | 695 | test_expect_success 'delete ref because entire history excluded' ' |
Felipe Contreras | 60ed264 | 2014-04-20 13:59:28 -0500 | [diff] [blame] | 696 | git branch to-delete && |
Elijah Newren | fdf31b6 | 2018-11-15 23:59:53 -0800 | [diff] [blame] | 697 | git fast-export to-delete ^to-delete >actual && |
| 698 | cat >expected <<-EOF && |
| 699 | reset refs/heads/to-delete |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 700 | from $ZERO_OID |
Elijah Newren | fdf31b6 | 2018-11-15 23:59:53 -0800 | [diff] [blame] | 701 | |
| 702 | EOF |
| 703 | test_cmp expected actual |
| 704 | ' |
| 705 | |
| 706 | test_expect_success 'delete refspec' ' |
| 707 | git fast-export --refspec :refs/heads/to-delete >actual && |
| 708 | cat >expected <<-EOF && |
Felipe Contreras | 60ed264 | 2014-04-20 13:59:28 -0500 | [diff] [blame] | 709 | reset refs/heads/to-delete |
brian m. carlson | 831279d | 2020-07-29 23:14:13 +0000 | [diff] [blame] | 710 | from $ZERO_OID |
Felipe Contreras | 60ed264 | 2014-04-20 13:59:28 -0500 | [diff] [blame] | 711 | |
| 712 | EOF |
| 713 | test_cmp expected actual |
| 714 | ' |
| 715 | |
Jonathan Tan | b3e8ca8 | 2017-09-20 16:55:02 -0700 | [diff] [blame] | 716 | test_expect_success 'when using -C, do not declare copy when source of copy is also modified' ' |
| 717 | test_create_repo src && |
| 718 | echo a_line >src/file.txt && |
| 719 | git -C src add file.txt && |
| 720 | git -C src commit -m 1st_commit && |
| 721 | |
| 722 | cp src/file.txt src/file2.txt && |
| 723 | echo another_line >>src/file.txt && |
| 724 | git -C src add file.txt file2.txt && |
| 725 | git -C src commit -m 2nd_commit && |
| 726 | |
| 727 | test_create_repo dst && |
Pratik Karki | a4d4e32 | 2018-03-27 23:16:37 +0545 | [diff] [blame] | 728 | git -C src fast-export --all -C >actual && |
| 729 | git -C dst fast-import <actual && |
Jonathan Tan | b3e8ca8 | 2017-09-20 16:55:02 -0700 | [diff] [blame] | 730 | git -C src show >expected && |
| 731 | git -C dst show >actual && |
| 732 | test_cmp expected actual |
| 733 | ' |
| 734 | |
Martin Ågren | be011bb | 2018-04-21 00:12:31 +0200 | [diff] [blame] | 735 | test_expect_success 'merge commit gets exported with --import-marks' ' |
| 736 | test_create_repo merging && |
| 737 | ( |
| 738 | cd merging && |
| 739 | test_commit initial && |
| 740 | git checkout -b topic && |
| 741 | test_commit on-topic && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 742 | git checkout main && |
| 743 | test_commit on-main && |
Martin Ågren | be011bb | 2018-04-21 00:12:31 +0200 | [diff] [blame] | 744 | test_tick && |
| 745 | git merge --no-ff -m Yeah topic && |
| 746 | |
| 747 | echo ":1 $(git rev-parse HEAD^^)" >marks && |
Johannes Schindelin | a881baa | 2020-11-18 23:44:42 +0000 | [diff] [blame] | 748 | git fast-export --import-marks=marks main >out && |
Martin Ågren | be011bb | 2018-04-21 00:12:31 +0200 | [diff] [blame] | 749 | grep Yeah out |
| 750 | ) |
| 751 | ' |
| 752 | |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 753 | test_done |