Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Shawn Pearce |
| 4 | # |
| 5 | |
Nanako Shiraishi | eaa2a6f | 2008-09-10 06:25:25 +0900 | [diff] [blame] | 6 | test_description='test git fast-import utility' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 7 | . ./test-lib.sh |
Junio C Hamano | bfdbee9 | 2008-08-08 02:26:28 -0700 | [diff] [blame] | 8 | . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 9 | |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 10 | verify_packs () { |
| 11 | for p in .git/objects/pack/*.pack |
| 12 | do |
| 13 | git verify-pack "$@" "$p" || return |
| 14 | done |
| 15 | } |
| 16 | |
Shawn O. Pearce | 8232dc4 | 2007-01-18 14:49:05 -0500 | [diff] [blame] | 17 | file2_data='file2 |
| 18 | second line of EOF' |
| 19 | |
| 20 | file3_data='EOF |
| 21 | in 3rd file |
| 22 | END' |
| 23 | |
| 24 | file4_data=abcd |
| 25 | file4_len=4 |
| 26 | |
Shawn O. Pearce | b715cfb | 2007-01-18 15:17:58 -0500 | [diff] [blame] | 27 | file5_data='an inline file. |
| 28 | we should see it later.' |
| 29 | |
| 30 | file6_data='#!/bin/sh |
| 31 | echo "$@"' |
| 32 | |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 33 | ### |
| 34 | ### series A |
| 35 | ### |
| 36 | |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 37 | test_expect_success 'empty stream succeeds' ' |
Eric Wong | d9545c7 | 2016-04-25 21:17:28 +0000 | [diff] [blame] | 38 | git config fastimport.unpackLimit 0 && |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 39 | git fast-import </dev/null |
| 40 | ' |
| 41 | |
Jeff King | b709043 | 2016-03-05 13:43:30 -0500 | [diff] [blame] | 42 | test_expect_success 'truncated stream complains' ' |
| 43 | echo "tag foo" | test_must_fail git fast-import |
| 44 | ' |
| 45 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 46 | test_expect_success 'A: create pack from stdin' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 47 | test_tick && |
| 48 | cat >input <<-INPUT_END && |
| 49 | blob |
| 50 | mark :2 |
| 51 | data <<EOF |
| 52 | $file2_data |
| 53 | EOF |
| 54 | |
| 55 | blob |
| 56 | mark :3 |
| 57 | data <<END |
| 58 | $file3_data |
| 59 | END |
| 60 | |
| 61 | blob |
| 62 | mark :4 |
| 63 | data $file4_len |
| 64 | $file4_data |
| 65 | commit refs/heads/master |
| 66 | mark :5 |
| 67 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 68 | data <<COMMIT |
| 69 | initial |
| 70 | COMMIT |
| 71 | |
| 72 | M 644 :2 file2 |
| 73 | M 644 :3 file3 |
| 74 | M 755 :4 file4 |
| 75 | |
| 76 | tag series-A |
| 77 | from :5 |
| 78 | data <<EOF |
| 79 | An annotated tag without a tagger |
| 80 | EOF |
| 81 | |
| 82 | tag series-A-blob |
| 83 | from :3 |
| 84 | data <<EOF |
| 85 | An annotated tag that annotates a blob. |
| 86 | EOF |
| 87 | |
| 88 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 89 | git fast-import --export-marks=marks.out <input && |
| 90 | git whatchanged master |
| 91 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 92 | |
| 93 | test_expect_success 'A: verify pack' ' |
| 94 | verify_packs |
| 95 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 96 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 97 | test_expect_success 'A: verify commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 98 | cat >expect <<-EOF && |
| 99 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 100 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 101 | |
| 102 | initial |
| 103 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 104 | git cat-file commit master | sed 1d >actual && |
| 105 | test_cmp expect actual |
| 106 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 107 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 108 | test_expect_success 'A: verify tree' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 109 | cat >expect <<-EOF && |
| 110 | 100644 blob file2 |
| 111 | 100644 blob file3 |
| 112 | 100755 blob file4 |
| 113 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 114 | git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 115 | test_cmp expect actual |
| 116 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 117 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 118 | test_expect_success 'A: verify file2' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 119 | echo "$file2_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 120 | git cat-file blob master:file2 >actual && |
| 121 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 122 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 123 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 124 | test_expect_success 'A: verify file3' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 125 | echo "$file3_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 126 | git cat-file blob master:file3 >actual && |
| 127 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 128 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 129 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 130 | test_expect_success 'A: verify file4' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 131 | printf "$file4_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 132 | git cat-file blob master:file4 >actual && |
| 133 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 134 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 135 | |
Junio C Hamano | 88fbf67 | 2008-12-19 14:41:21 -0800 | [diff] [blame] | 136 | test_expect_success 'A: verify tag/series-A' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 137 | cat >expect <<-EOF && |
| 138 | object $(git rev-parse refs/heads/master) |
| 139 | type commit |
| 140 | tag series-A |
| 141 | |
| 142 | An annotated tag without a tagger |
| 143 | EOF |
Junio C Hamano | 88fbf67 | 2008-12-19 14:41:21 -0800 | [diff] [blame] | 144 | git cat-file tag tags/series-A >actual && |
| 145 | test_cmp expect actual |
| 146 | ' |
| 147 | |
Dmitry Ivankov | 2efe38e | 2011-08-22 18:10:18 +0600 | [diff] [blame] | 148 | test_expect_success 'A: verify tag/series-A-blob' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 149 | cat >expect <<-EOF && |
| 150 | object $(git rev-parse refs/heads/master:file3) |
| 151 | type blob |
| 152 | tag series-A-blob |
| 153 | |
| 154 | An annotated tag that annotates a blob. |
| 155 | EOF |
Dmitry Ivankov | 2efe38e | 2011-08-22 18:10:18 +0600 | [diff] [blame] | 156 | git cat-file tag tags/series-A-blob >actual && |
| 157 | test_cmp expect actual |
| 158 | ' |
| 159 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 160 | test_expect_success 'A: verify marks output' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 161 | cat >expect <<-EOF && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 162 | :2 $(git rev-parse --verify master:file2) |
| 163 | :3 $(git rev-parse --verify master:file3) |
| 164 | :4 $(git rev-parse --verify master:file4) |
| 165 | :5 $(git rev-parse --verify master^0) |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 166 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 167 | test_cmp expect marks.out |
| 168 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 169 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 170 | test_expect_success 'A: verify marks import' ' |
| 171 | git fast-import \ |
Shawn O. Pearce | e843842 | 2007-03-07 18:07:26 -0500 | [diff] [blame] | 172 | --import-marks=marks.out \ |
| 173 | --export-marks=marks.new \ |
| 174 | </dev/null && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 175 | test_cmp expect marks.new |
| 176 | ' |
Shawn O. Pearce | e843842 | 2007-03-07 18:07:26 -0500 | [diff] [blame] | 177 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 178 | test_expect_success 'A: tag blob by sha1' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 179 | test_tick && |
| 180 | new_blob=$(echo testing | git hash-object --stdin) && |
| 181 | cat >input <<-INPUT_END && |
| 182 | tag series-A-blob-2 |
| 183 | from $(git rev-parse refs/heads/master:file3) |
| 184 | data <<EOF |
| 185 | Tag blob by sha1. |
| 186 | EOF |
| 187 | |
| 188 | blob |
| 189 | mark :6 |
| 190 | data <<EOF |
| 191 | testing |
| 192 | EOF |
| 193 | |
| 194 | commit refs/heads/new_blob |
| 195 | committer <> 0 +0000 |
| 196 | data 0 |
| 197 | M 644 :6 new_blob |
| 198 | #pretend we got sha1 from fast-import |
| 199 | ls "new_blob" |
| 200 | |
| 201 | tag series-A-blob-3 |
| 202 | from $new_blob |
| 203 | data <<EOF |
| 204 | Tag new_blob. |
| 205 | EOF |
| 206 | INPUT_END |
| 207 | |
| 208 | cat >expect <<-EOF && |
| 209 | object $(git rev-parse refs/heads/master:file3) |
| 210 | type blob |
| 211 | tag series-A-blob-2 |
| 212 | |
| 213 | Tag blob by sha1. |
| 214 | object $new_blob |
| 215 | type blob |
| 216 | tag series-A-blob-3 |
| 217 | |
| 218 | Tag new_blob. |
| 219 | EOF |
| 220 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 221 | git fast-import <input && |
Dmitry Ivankov | 2efe38e | 2011-08-22 18:10:18 +0600 | [diff] [blame] | 222 | git cat-file tag tags/series-A-blob-2 >actual && |
Dmitry Ivankov | 6c447f6 | 2011-08-22 18:10:19 +0600 | [diff] [blame] | 223 | git cat-file tag tags/series-A-blob-3 >>actual && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 224 | test_cmp expect actual |
| 225 | ' |
Dmitry Ivankov | 2efe38e | 2011-08-22 18:10:18 +0600 | [diff] [blame] | 226 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 227 | test_expect_success 'A: verify marks import does not crash' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 228 | test_tick && |
| 229 | cat >input <<-INPUT_END && |
| 230 | commit refs/heads/verify--import-marks |
| 231 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 232 | data <<COMMIT |
| 233 | recreate from :5 |
| 234 | COMMIT |
| 235 | |
| 236 | from :5 |
| 237 | M 755 :2 copy-of-file2 |
| 238 | |
| 239 | INPUT_END |
| 240 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 241 | git fast-import --import-marks=marks.out <input && |
| 242 | git whatchanged verify--import-marks |
| 243 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 244 | |
| 245 | test_expect_success 'A: verify pack' ' |
| 246 | verify_packs |
| 247 | ' |
| 248 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 249 | test_expect_success 'A: verify diff' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 250 | cat >expect <<-EOF && |
| 251 | :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2 |
| 252 | EOF |
| 253 | git diff-tree -M -r master verify--import-marks >actual && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 254 | compare_diff_raw expect actual && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 255 | test $(git rev-parse --verify master:file2) \ |
| 256 | = $(git rev-parse --verify verify--import-marks:copy-of-file2) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 257 | ' |
Shawn O. Pearce | aac65ed | 2007-05-24 00:32:31 -0400 | [diff] [blame] | 258 | |
Raja R Harinath | 7e7db5e | 2010-07-13 17:21:48 +0530 | [diff] [blame] | 259 | test_expect_success 'A: export marks with large values' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 260 | test_tick && |
| 261 | mt=$(git hash-object --stdin < /dev/null) && |
| 262 | >input.blob && |
| 263 | >marks.exp && |
| 264 | >tree.exp && |
| 265 | |
| 266 | cat >input.commit <<-EOF && |
| 267 | commit refs/heads/verify--dump-marks |
| 268 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 269 | data <<COMMIT |
| 270 | test the sparse array dumping routines with exponentially growing marks |
| 271 | COMMIT |
| 272 | EOF |
| 273 | |
| 274 | i=0 l=4 m=6 n=7 && |
| 275 | while test "$i" -lt 27 |
| 276 | do |
| 277 | cat >>input.blob <<-EOF && |
| 278 | blob |
| 279 | mark :$l |
| 280 | data 0 |
| 281 | blob |
| 282 | mark :$m |
| 283 | data 0 |
| 284 | blob |
| 285 | mark :$n |
| 286 | data 0 |
| 287 | EOF |
| 288 | echo "M 100644 :$l l$i" >>input.commit && |
| 289 | echo "M 100644 :$m m$i" >>input.commit && |
| 290 | echo "M 100644 :$n n$i" >>input.commit && |
| 291 | |
| 292 | echo ":$l $mt" >>marks.exp && |
| 293 | echo ":$m $mt" >>marks.exp && |
| 294 | echo ":$n $mt" >>marks.exp && |
| 295 | |
| 296 | printf "100644 blob $mt\tl$i\n" >>tree.exp && |
| 297 | printf "100644 blob $mt\tm$i\n" >>tree.exp && |
| 298 | printf "100644 blob $mt\tn$i\n" >>tree.exp && |
| 299 | |
| 300 | l=$(($l + $l)) && |
| 301 | m=$(($m + $m)) && |
| 302 | n=$(($l + $n)) && |
| 303 | |
| 304 | i=$((1 + $i)) || return 1 |
| 305 | done && |
| 306 | |
| 307 | sort tree.exp > tree.exp_s && |
| 308 | |
Raja R Harinath | 7e7db5e | 2010-07-13 17:21:48 +0530 | [diff] [blame] | 309 | cat input.blob input.commit | git fast-import --export-marks=marks.large && |
| 310 | git ls-tree refs/heads/verify--dump-marks >tree.out && |
| 311 | test_cmp tree.exp_s tree.out && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 312 | test_cmp marks.exp marks.large |
| 313 | ' |
Raja R Harinath | 7e7db5e | 2010-07-13 17:21:48 +0530 | [diff] [blame] | 314 | |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 315 | ### |
| 316 | ### series B |
| 317 | ### |
| 318 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 319 | test_expect_success 'B: fail on invalid blob sha1' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 320 | test_tick && |
| 321 | cat >input <<-INPUT_END && |
| 322 | commit refs/heads/branch |
| 323 | mark :1 |
| 324 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 325 | data <<COMMIT |
| 326 | corrupt |
| 327 | COMMIT |
| 328 | |
| 329 | from refs/heads/master |
| 330 | M 755 0000000000000000000000000000000000000001 zero1 |
| 331 | |
| 332 | INPUT_END |
| 333 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 334 | test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 335 | test_must_fail git fast-import <input |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 336 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 337 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 338 | test_expect_success 'B: accept branch name "TEMP_TAG"' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 339 | cat >input <<-INPUT_END && |
| 340 | commit TEMP_TAG |
| 341 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 342 | data <<COMMIT |
| 343 | tag base |
| 344 | COMMIT |
| 345 | |
| 346 | from refs/heads/master |
| 347 | |
| 348 | INPUT_END |
| 349 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 350 | test_when_finished "rm -f .git/TEMP_TAG |
| 351 | git gc |
| 352 | git prune" && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 353 | git fast-import <input && |
| 354 | test -f .git/TEMP_TAG && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 355 | test $(git rev-parse master) = $(git rev-parse TEMP_TAG^) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 356 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 357 | |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 358 | test_expect_success 'B: accept empty committer' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 359 | cat >input <<-INPUT_END && |
| 360 | commit refs/heads/empty-committer-1 |
| 361 | committer <> $GIT_COMMITTER_DATE |
| 362 | data <<COMMIT |
| 363 | empty commit |
| 364 | COMMIT |
| 365 | INPUT_END |
| 366 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 367 | test_when_finished "git update-ref -d refs/heads/empty-committer-1 |
| 368 | git gc |
| 369 | git prune" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 370 | git fast-import <input && |
| 371 | out=$(git fsck) && |
| 372 | echo "$out" && |
| 373 | test -z "$out" |
| 374 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 375 | |
Dmitry Ivankov | 17fb007 | 2011-08-11 16:21:07 +0600 | [diff] [blame] | 376 | test_expect_success 'B: accept and fixup committer with no name' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 377 | cat >input <<-INPUT_END && |
| 378 | commit refs/heads/empty-committer-2 |
| 379 | committer <a@b.com> $GIT_COMMITTER_DATE |
| 380 | data <<COMMIT |
| 381 | empty commit |
| 382 | COMMIT |
| 383 | INPUT_END |
| 384 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 385 | test_when_finished "git update-ref -d refs/heads/empty-committer-2 |
| 386 | git gc |
| 387 | git prune" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 388 | git fast-import <input && |
| 389 | out=$(git fsck) && |
| 390 | echo "$out" && |
| 391 | test -z "$out" |
| 392 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 393 | |
Dmitry Ivankov | 4b4963c | 2011-08-11 16:21:08 +0600 | [diff] [blame] | 394 | test_expect_success 'B: fail on invalid committer (1)' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 395 | cat >input <<-INPUT_END && |
| 396 | commit refs/heads/invalid-committer |
| 397 | committer Name email> $GIT_COMMITTER_DATE |
| 398 | data <<COMMIT |
| 399 | empty commit |
| 400 | COMMIT |
| 401 | INPUT_END |
| 402 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 403 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 404 | test_must_fail git fast-import <input |
| 405 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 406 | |
Dmitry Ivankov | 4b4963c | 2011-08-11 16:21:08 +0600 | [diff] [blame] | 407 | test_expect_success 'B: fail on invalid committer (2)' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 408 | cat >input <<-INPUT_END && |
| 409 | commit refs/heads/invalid-committer |
| 410 | committer Name <e<mail> $GIT_COMMITTER_DATE |
| 411 | data <<COMMIT |
| 412 | empty commit |
| 413 | COMMIT |
| 414 | INPUT_END |
| 415 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 416 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 417 | test_must_fail git fast-import <input |
| 418 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 419 | |
Dmitry Ivankov | 4b4963c | 2011-08-11 16:21:08 +0600 | [diff] [blame] | 420 | test_expect_success 'B: fail on invalid committer (3)' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 421 | cat >input <<-INPUT_END && |
| 422 | commit refs/heads/invalid-committer |
| 423 | committer Name <email>> $GIT_COMMITTER_DATE |
| 424 | data <<COMMIT |
| 425 | empty commit |
| 426 | COMMIT |
| 427 | INPUT_END |
| 428 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 429 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 430 | test_must_fail git fast-import <input |
| 431 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 432 | |
Dmitry Ivankov | 4b4963c | 2011-08-11 16:21:08 +0600 | [diff] [blame] | 433 | test_expect_success 'B: fail on invalid committer (4)' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 434 | cat >input <<-INPUT_END && |
| 435 | commit refs/heads/invalid-committer |
| 436 | committer Name <email $GIT_COMMITTER_DATE |
| 437 | data <<COMMIT |
| 438 | empty commit |
| 439 | COMMIT |
| 440 | INPUT_END |
| 441 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 442 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 443 | test_must_fail git fast-import <input |
| 444 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 445 | |
Dmitry Ivankov | 4b4963c | 2011-08-11 16:21:08 +0600 | [diff] [blame] | 446 | test_expect_success 'B: fail on invalid committer (5)' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 447 | cat >input <<-INPUT_END && |
| 448 | commit refs/heads/invalid-committer |
| 449 | committer Name<email> $GIT_COMMITTER_DATE |
| 450 | data <<COMMIT |
| 451 | empty commit |
| 452 | COMMIT |
| 453 | INPUT_END |
| 454 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 455 | test_when_finished "git update-ref -d refs/heads/invalid-committer" && |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 456 | test_must_fail git fast-import <input |
| 457 | ' |
Dmitry Ivankov | 4cedb78 | 2011-08-11 16:21:06 +0600 | [diff] [blame] | 458 | |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 459 | ### |
| 460 | ### series C |
| 461 | ### |
| 462 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 463 | test_expect_success 'C: incremental import create pack from stdin' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 464 | newf=$(echo hi newf | git hash-object -w --stdin) && |
| 465 | oldf=$(git rev-parse --verify master:file2) && |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 466 | test_tick && |
| 467 | cat >input <<-INPUT_END && |
| 468 | commit refs/heads/branch |
| 469 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 470 | data <<COMMIT |
| 471 | second |
| 472 | COMMIT |
| 473 | |
| 474 | from refs/heads/master |
| 475 | M 644 $oldf file2/oldf |
| 476 | M 755 $newf file2/newf |
| 477 | D file3 |
| 478 | |
| 479 | INPUT_END |
| 480 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 481 | git fast-import <input && |
| 482 | git whatchanged branch |
| 483 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 484 | |
| 485 | test_expect_success 'C: verify pack' ' |
| 486 | verify_packs |
| 487 | ' |
| 488 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 489 | test_expect_success 'C: validate reuse existing blob' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 490 | test $newf = $(git rev-parse --verify branch:file2/newf) && |
| 491 | test $oldf = $(git rev-parse --verify branch:file2/oldf) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 492 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 493 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 494 | test_expect_success 'C: verify commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 495 | cat >expect <<-EOF && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 496 | parent $(git rev-parse --verify master^0) |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 497 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 498 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 499 | |
| 500 | second |
| 501 | EOF |
| 502 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 503 | git cat-file commit branch | sed 1d >actual && |
| 504 | test_cmp expect actual |
| 505 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 506 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 507 | test_expect_success 'C: validate rename result' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 508 | cat >expect <<-EOF && |
| 509 | :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf |
| 510 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf |
| 511 | :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3 |
| 512 | EOF |
| 513 | git diff-tree -M -r master branch >actual && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 514 | compare_diff_raw expect actual |
| 515 | ' |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 516 | |
Shawn O. Pearce | b715cfb | 2007-01-18 15:17:58 -0500 | [diff] [blame] | 517 | ### |
| 518 | ### series D |
| 519 | ### |
| 520 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 521 | test_expect_success 'D: inline data in commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 522 | test_tick && |
| 523 | cat >input <<-INPUT_END && |
| 524 | commit refs/heads/branch |
| 525 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 526 | data <<COMMIT |
| 527 | third |
| 528 | COMMIT |
| 529 | |
| 530 | from refs/heads/branch^0 |
| 531 | M 644 inline newdir/interesting |
| 532 | data <<EOF |
| 533 | $file5_data |
| 534 | EOF |
| 535 | |
| 536 | M 755 inline newdir/exec.sh |
| 537 | data <<EOF |
| 538 | $file6_data |
| 539 | EOF |
| 540 | |
| 541 | INPUT_END |
| 542 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 543 | git fast-import <input && |
| 544 | git whatchanged branch |
| 545 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 546 | |
| 547 | test_expect_success 'D: verify pack' ' |
| 548 | verify_packs |
| 549 | ' |
Shawn O. Pearce | b715cfb | 2007-01-18 15:17:58 -0500 | [diff] [blame] | 550 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 551 | test_expect_success 'D: validate new files added' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 552 | cat >expect <<-EOF && |
| 553 | :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh |
| 554 | :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting |
| 555 | EOF |
| 556 | git diff-tree -M -r branch^ branch >actual && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 557 | compare_diff_raw expect actual |
| 558 | ' |
Shawn O. Pearce | b715cfb | 2007-01-18 15:17:58 -0500 | [diff] [blame] | 559 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 560 | test_expect_success 'D: verify file5' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 561 | echo "$file5_data" >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 562 | git cat-file blob branch:newdir/interesting >actual && |
| 563 | test_cmp expect actual |
| 564 | ' |
Shawn O. Pearce | b715cfb | 2007-01-18 15:17:58 -0500 | [diff] [blame] | 565 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 566 | test_expect_success 'D: verify file6' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 567 | echo "$file6_data" >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 568 | git cat-file blob branch:newdir/exec.sh >actual && |
| 569 | test_cmp expect actual |
| 570 | ' |
Shawn O. Pearce | b715cfb | 2007-01-18 15:17:58 -0500 | [diff] [blame] | 571 | |
Shawn O. Pearce | 63e0c8b | 2007-02-06 14:58:30 -0500 | [diff] [blame] | 572 | ### |
| 573 | ### series E |
| 574 | ### |
| 575 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 576 | test_expect_success 'E: rfc2822 date, --date-format=raw' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 577 | cat >input <<-INPUT_END && |
| 578 | commit refs/heads/branch |
| 579 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 |
| 580 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 |
| 581 | data <<COMMIT |
| 582 | RFC 2822 type date |
| 583 | COMMIT |
| 584 | |
| 585 | from refs/heads/branch^0 |
| 586 | |
| 587 | INPUT_END |
| 588 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 589 | test_must_fail git fast-import --date-format=raw <input |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 590 | ' |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 591 | test_expect_success 'E: rfc2822 date, --date-format=rfc2822' ' |
| 592 | git fast-import --date-format=rfc2822 <input |
| 593 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 594 | |
| 595 | test_expect_success 'E: verify pack' ' |
| 596 | verify_packs |
| 597 | ' |
Shawn O. Pearce | 63e0c8b | 2007-02-06 14:58:30 -0500 | [diff] [blame] | 598 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 599 | test_expect_success 'E: verify commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 600 | cat >expect <<-EOF && |
| 601 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 |
| 602 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 |
| 603 | |
| 604 | RFC 2822 type date |
| 605 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 606 | git cat-file commit branch | sed 1,2d >actual && |
| 607 | test_cmp expect actual |
| 608 | ' |
Shawn O. Pearce | 63e0c8b | 2007-02-06 14:58:30 -0500 | [diff] [blame] | 609 | |
Shawn O. Pearce | 7073e69 | 2007-02-06 16:08:06 -0500 | [diff] [blame] | 610 | ### |
| 611 | ### series F |
| 612 | ### |
| 613 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 614 | test_expect_success 'F: non-fast-forward update skips' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 615 | old_branch=$(git rev-parse --verify branch^0) && |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 616 | test_tick && |
| 617 | cat >input <<-INPUT_END && |
| 618 | commit refs/heads/branch |
| 619 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 620 | data <<COMMIT |
| 621 | losing things already? |
| 622 | COMMIT |
| 623 | |
| 624 | from refs/heads/branch~1 |
| 625 | |
| 626 | reset refs/heads/other |
| 627 | from refs/heads/branch |
| 628 | |
| 629 | INPUT_END |
| 630 | |
Johannes Sixt | b08d82f | 2015-11-19 20:09:44 +0100 | [diff] [blame] | 631 | test_must_fail git fast-import <input && |
| 632 | # branch must remain unaffected |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 633 | test $old_branch = $(git rev-parse --verify branch^0) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 634 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 635 | |
| 636 | test_expect_success 'F: verify pack' ' |
| 637 | verify_packs |
| 638 | ' |
Shawn O. Pearce | 7073e69 | 2007-02-06 16:08:06 -0500 | [diff] [blame] | 639 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 640 | test_expect_success 'F: verify other commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 641 | cat >expect <<-EOF && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 642 | tree $(git rev-parse branch~1^{tree}) |
| 643 | parent $(git rev-parse branch~1) |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 644 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 645 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 646 | |
| 647 | losing things already? |
| 648 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 649 | git cat-file commit other >actual && |
| 650 | test_cmp expect actual |
| 651 | ' |
Shawn O. Pearce | 7073e69 | 2007-02-06 16:08:06 -0500 | [diff] [blame] | 652 | |
| 653 | ### |
| 654 | ### series G |
| 655 | ### |
| 656 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 657 | test_expect_success 'G: non-fast-forward update forced' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 658 | old_branch=$(git rev-parse --verify branch^0) && |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 659 | test_tick && |
| 660 | cat >input <<-INPUT_END && |
| 661 | commit refs/heads/branch |
| 662 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 663 | data <<COMMIT |
| 664 | losing things already? |
| 665 | COMMIT |
| 666 | |
| 667 | from refs/heads/branch~1 |
| 668 | |
| 669 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 670 | git fast-import --force <input |
| 671 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 672 | |
| 673 | test_expect_success 'G: verify pack' ' |
| 674 | verify_packs |
| 675 | ' |
| 676 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 677 | test_expect_success 'G: branch changed, but logged' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 678 | test $old_branch != $(git rev-parse --verify branch^0) && |
| 679 | test $old_branch = $(git rev-parse --verify branch@{1}) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 680 | ' |
Shawn O. Pearce | 7073e69 | 2007-02-06 16:08:06 -0500 | [diff] [blame] | 681 | |
Shawn O. Pearce | 825769a | 2007-02-07 02:03:03 -0500 | [diff] [blame] | 682 | ### |
| 683 | ### series H |
| 684 | ### |
| 685 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 686 | test_expect_success 'H: deletall, add 1' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 687 | test_tick && |
| 688 | cat >input <<-INPUT_END && |
| 689 | commit refs/heads/H |
| 690 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 691 | data <<COMMIT |
| 692 | third |
| 693 | COMMIT |
| 694 | |
| 695 | from refs/heads/branch^0 |
| 696 | M 644 inline i-will-die |
| 697 | data <<EOF |
| 698 | this file will never exist. |
| 699 | EOF |
| 700 | |
| 701 | deleteall |
| 702 | M 644 inline h/e/l/lo |
| 703 | data <<EOF |
| 704 | $file5_data |
| 705 | EOF |
| 706 | |
| 707 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 708 | git fast-import <input && |
| 709 | git whatchanged H |
| 710 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 711 | |
| 712 | test_expect_success 'H: verify pack' ' |
| 713 | verify_packs |
| 714 | ' |
Shawn O. Pearce | 825769a | 2007-02-07 02:03:03 -0500 | [diff] [blame] | 715 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 716 | test_expect_success 'H: validate old files removed, new files added' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 717 | cat >expect <<-EOF && |
| 718 | :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf |
| 719 | :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf |
| 720 | :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4 |
| 721 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo |
| 722 | :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh |
| 723 | EOF |
| 724 | git diff-tree -M -r H^ H >actual && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 725 | compare_diff_raw expect actual |
| 726 | ' |
Shawn O. Pearce | 825769a | 2007-02-07 02:03:03 -0500 | [diff] [blame] | 727 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 728 | test_expect_success 'H: verify file' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 729 | echo "$file5_data" >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 730 | git cat-file blob H:h/e/l/lo >actual && |
| 731 | test_cmp expect actual |
| 732 | ' |
Shawn O. Pearce | 825769a | 2007-02-07 02:03:03 -0500 | [diff] [blame] | 733 | |
Shawn O. Pearce | bdf1c06 | 2007-02-11 19:45:56 -0500 | [diff] [blame] | 734 | ### |
| 735 | ### series I |
| 736 | ### |
| 737 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 738 | test_expect_success 'I: export-pack-edges' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 739 | cat >input <<-INPUT_END && |
| 740 | commit refs/heads/export-boundary |
| 741 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 742 | data <<COMMIT |
| 743 | we have a border. its only 40 characters wide. |
| 744 | COMMIT |
| 745 | |
| 746 | from refs/heads/branch |
| 747 | |
| 748 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 749 | git fast-import --export-pack-edges=edges.list <input |
| 750 | ' |
Shawn O. Pearce | bdf1c06 | 2007-02-11 19:45:56 -0500 | [diff] [blame] | 751 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 752 | test_expect_success 'I: verify edge list' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 753 | cat >expect <<-EOF && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 754 | .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary) |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 755 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 756 | sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && |
| 757 | test_cmp expect actual |
| 758 | ' |
Shawn O. Pearce | bdf1c06 | 2007-02-11 19:45:56 -0500 | [diff] [blame] | 759 | |
Shawn O. Pearce | ea5e370 | 2007-02-12 04:08:43 -0500 | [diff] [blame] | 760 | ### |
| 761 | ### series J |
| 762 | ### |
| 763 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 764 | test_expect_success 'J: reset existing branch creates empty commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 765 | cat >input <<-INPUT_END && |
| 766 | commit refs/heads/J |
| 767 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 768 | data <<COMMIT |
| 769 | create J |
| 770 | COMMIT |
| 771 | |
| 772 | from refs/heads/branch |
| 773 | |
| 774 | reset refs/heads/J |
| 775 | |
| 776 | commit refs/heads/J |
| 777 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 778 | data <<COMMIT |
| 779 | initialize J |
| 780 | COMMIT |
| 781 | |
| 782 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 783 | git fast-import <input |
| 784 | ' |
| 785 | test_expect_success 'J: branch has 1 commit, empty tree' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 786 | test 1 = $(git rev-list J | wc -l) && |
| 787 | test 0 = $(git ls-tree J | wc -l) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 788 | ' |
Shawn O. Pearce | ea5e370 | 2007-02-12 04:08:43 -0500 | [diff] [blame] | 789 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 790 | test_expect_success 'J: tag must fail on empty branch' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 791 | cat >input <<-INPUT_END && |
| 792 | reset refs/heads/J2 |
| 793 | |
| 794 | tag wrong_tag |
| 795 | from refs/heads/J2 |
| 796 | data <<EOF |
| 797 | Tag branch that was reset. |
| 798 | EOF |
| 799 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 800 | test_must_fail git fast-import <input |
| 801 | ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 802 | |
Shawn O. Pearce | ea5e370 | 2007-02-12 04:08:43 -0500 | [diff] [blame] | 803 | ### |
| 804 | ### series K |
| 805 | ### |
| 806 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 807 | test_expect_success 'K: reinit branch with from' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 808 | cat >input <<-INPUT_END && |
| 809 | commit refs/heads/K |
| 810 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 811 | data <<COMMIT |
| 812 | create K |
| 813 | COMMIT |
| 814 | |
| 815 | from refs/heads/branch |
| 816 | |
| 817 | commit refs/heads/K |
| 818 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 819 | data <<COMMIT |
| 820 | redo K |
| 821 | COMMIT |
| 822 | |
| 823 | from refs/heads/branch^1 |
| 824 | |
| 825 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 826 | git fast-import <input |
| 827 | ' |
| 828 | test_expect_success 'K: verify K^1 = branch^1' ' |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 829 | test $(git rev-parse --verify branch^1) \ |
| 830 | = $(git rev-parse --verify K^1) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 831 | ' |
Shawn O. Pearce | ea5e370 | 2007-02-12 04:08:43 -0500 | [diff] [blame] | 832 | |
Jeff King | e741130 | 2007-03-12 14:58:50 -0400 | [diff] [blame] | 833 | ### |
| 834 | ### series L |
| 835 | ### |
| 836 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 837 | test_expect_success 'L: verify internal tree sorting' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 838 | cat >input <<-INPUT_END && |
| 839 | blob |
| 840 | mark :1 |
| 841 | data <<EOF |
| 842 | some data |
| 843 | EOF |
| 844 | |
| 845 | blob |
| 846 | mark :2 |
| 847 | data <<EOF |
| 848 | other data |
| 849 | EOF |
| 850 | |
| 851 | commit refs/heads/L |
| 852 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 853 | data <<COMMIT |
| 854 | create L |
| 855 | COMMIT |
| 856 | |
| 857 | M 644 :1 b. |
| 858 | M 644 :1 b/other |
| 859 | M 644 :1 ba |
| 860 | |
| 861 | commit refs/heads/L |
| 862 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 863 | data <<COMMIT |
| 864 | update L |
| 865 | COMMIT |
| 866 | |
| 867 | M 644 :2 b. |
| 868 | M 644 :2 b/other |
| 869 | M 644 :2 ba |
| 870 | INPUT_END |
| 871 | |
| 872 | cat >expect <<-EXPECT_END && |
| 873 | :100644 100644 4268632... 55d3a52... M b. |
| 874 | :040000 040000 0ae5cac... 443c768... M b |
| 875 | :100644 100644 4268632... 55d3a52... M ba |
| 876 | EXPECT_END |
| 877 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 878 | git fast-import <input && |
Ann T Ropea | a2cd709 | 2017-12-03 22:27:39 +0100 | [diff] [blame] | 879 | GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev --raw L^ L >output && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 880 | test_cmp expect output |
| 881 | ' |
Jeff King | e741130 | 2007-03-12 14:58:50 -0400 | [diff] [blame] | 882 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 883 | test_expect_success 'L: nested tree copy does not corrupt deltas' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 884 | cat >input <<-INPUT_END && |
| 885 | blob |
| 886 | mark :1 |
| 887 | data <<EOF |
| 888 | the data |
| 889 | EOF |
| 890 | |
| 891 | commit refs/heads/L2 |
| 892 | committer C O Mitter <committer@example.com> 1112912473 -0700 |
| 893 | data <<COMMIT |
| 894 | init L2 |
| 895 | COMMIT |
| 896 | M 644 :1 a/b/c |
| 897 | M 644 :1 a/b/d |
| 898 | M 644 :1 a/e/f |
| 899 | |
| 900 | commit refs/heads/L2 |
| 901 | committer C O Mitter <committer@example.com> 1112912473 -0700 |
| 902 | data <<COMMIT |
| 903 | update L2 |
| 904 | COMMIT |
| 905 | C a g |
| 906 | C a/e g/b |
| 907 | M 644 :1 g/b/h |
| 908 | INPUT_END |
| 909 | |
| 910 | cat >expect <<-\EOF && |
| 911 | g/b/f |
| 912 | g/b/h |
| 913 | EOF |
| 914 | |
Johannes Sixt | 93e911f | 2015-11-19 20:09:47 +0100 | [diff] [blame] | 915 | test_when_finished "git update-ref -d refs/heads/L2" && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 916 | git fast-import <input && |
Dmitry Ivankov | 9a0edb7 | 2011-08-15 00:32:23 +0600 | [diff] [blame] | 917 | git ls-tree L2 g/b/ >tmp && |
| 918 | cat tmp | cut -f 2 >actual && |
| 919 | test_cmp expect actual && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 920 | git fsck $(git rev-parse L2) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 921 | ' |
Dmitry Ivankov | 9a0edb7 | 2011-08-15 00:32:23 +0600 | [diff] [blame] | 922 | |
Shawn O. Pearce | f39a946 | 2007-07-09 22:58:23 -0400 | [diff] [blame] | 923 | ### |
| 924 | ### series M |
| 925 | ### |
| 926 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 927 | test_expect_success 'M: rename file in same subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 928 | test_tick && |
| 929 | cat >input <<-INPUT_END && |
| 930 | commit refs/heads/M1 |
| 931 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 932 | data <<COMMIT |
| 933 | file rename |
| 934 | COMMIT |
| 935 | |
| 936 | from refs/heads/branch^0 |
| 937 | R file2/newf file2/n.e.w.f |
| 938 | |
| 939 | INPUT_END |
| 940 | |
| 941 | cat >expect <<-EOF && |
| 942 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f |
| 943 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 944 | git fast-import <input && |
| 945 | git diff-tree -M -r M1^ M1 >actual && |
| 946 | compare_diff_raw expect actual |
| 947 | ' |
Shawn O. Pearce | f39a946 | 2007-07-09 22:58:23 -0400 | [diff] [blame] | 948 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 949 | test_expect_success 'M: rename file to new subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 950 | cat >input <<-INPUT_END && |
| 951 | commit refs/heads/M2 |
| 952 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 953 | data <<COMMIT |
| 954 | file rename |
| 955 | COMMIT |
| 956 | |
| 957 | from refs/heads/branch^0 |
| 958 | R file2/newf i/am/new/to/you |
| 959 | |
| 960 | INPUT_END |
| 961 | |
| 962 | cat >expect <<-EOF && |
| 963 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you |
| 964 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 965 | git fast-import <input && |
| 966 | git diff-tree -M -r M2^ M2 >actual && |
| 967 | compare_diff_raw expect actual |
| 968 | ' |
Shawn O. Pearce | f39a946 | 2007-07-09 22:58:23 -0400 | [diff] [blame] | 969 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 970 | test_expect_success 'M: rename subdirectory to new subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 971 | cat >input <<-INPUT_END && |
| 972 | commit refs/heads/M3 |
| 973 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 974 | data <<COMMIT |
| 975 | file rename |
| 976 | COMMIT |
| 977 | |
| 978 | from refs/heads/M2^0 |
| 979 | R i other/sub |
| 980 | |
| 981 | INPUT_END |
| 982 | |
| 983 | cat >expect <<-EOF && |
| 984 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you |
| 985 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 986 | git fast-import <input && |
| 987 | git diff-tree -M -r M3^ M3 >actual && |
| 988 | compare_diff_raw expect actual |
| 989 | ' |
Shawn O. Pearce | f39a946 | 2007-07-09 22:58:23 -0400 | [diff] [blame] | 990 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 991 | test_expect_success 'M: rename root to subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 992 | cat >input <<-INPUT_END && |
| 993 | commit refs/heads/M4 |
| 994 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 995 | data <<COMMIT |
| 996 | rename root |
| 997 | COMMIT |
| 998 | |
| 999 | from refs/heads/M2^0 |
| 1000 | R "" sub |
| 1001 | |
| 1002 | INPUT_END |
| 1003 | |
| 1004 | cat >expect <<-EOF && |
| 1005 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf |
| 1006 | :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4 |
| 1007 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you |
| 1008 | :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh |
| 1009 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting |
| 1010 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1011 | git fast-import <input && |
| 1012 | git diff-tree -M -r M4^ M4 >actual && |
| 1013 | cat actual && |
| 1014 | compare_diff_raw expect actual |
| 1015 | ' |
John Keeping | aca7061 | 2013-06-23 15:58:19 +0100 | [diff] [blame] | 1016 | |
Shawn O. Pearce | b6f3481 | 2007-07-15 01:40:37 -0400 | [diff] [blame] | 1017 | ### |
| 1018 | ### series N |
| 1019 | ### |
| 1020 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1021 | test_expect_success 'N: copy file in same subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1022 | test_tick && |
| 1023 | cat >input <<-INPUT_END && |
| 1024 | commit refs/heads/N1 |
| 1025 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1026 | data <<COMMIT |
| 1027 | file copy |
| 1028 | COMMIT |
| 1029 | |
| 1030 | from refs/heads/branch^0 |
| 1031 | C file2/newf file2/n.e.w.f |
| 1032 | |
| 1033 | INPUT_END |
| 1034 | |
| 1035 | cat >expect <<-EOF && |
| 1036 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f |
| 1037 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1038 | git fast-import <input && |
| 1039 | git diff-tree -C --find-copies-harder -r N1^ N1 >actual && |
| 1040 | compare_diff_raw expect actual |
| 1041 | ' |
Shawn O. Pearce | b6f3481 | 2007-07-15 01:40:37 -0400 | [diff] [blame] | 1042 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1043 | test_expect_success 'N: copy then modify subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1044 | cat >input <<-INPUT_END && |
| 1045 | commit refs/heads/N2 |
| 1046 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1047 | data <<COMMIT |
| 1048 | clean directory copy |
| 1049 | COMMIT |
| 1050 | |
| 1051 | from refs/heads/branch^0 |
| 1052 | C file2 file3 |
| 1053 | |
| 1054 | commit refs/heads/N2 |
| 1055 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1056 | data <<COMMIT |
| 1057 | modify directory copy |
| 1058 | COMMIT |
| 1059 | |
| 1060 | M 644 inline file3/file5 |
| 1061 | data <<EOF |
| 1062 | $file5_data |
| 1063 | EOF |
| 1064 | |
| 1065 | INPUT_END |
| 1066 | |
| 1067 | cat >expect <<-EOF && |
| 1068 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 |
| 1069 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf |
| 1070 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf |
| 1071 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1072 | git fast-import <input && |
| 1073 | git diff-tree -C --find-copies-harder -r N2^^ N2 >actual && |
| 1074 | compare_diff_raw expect actual |
| 1075 | ' |
Shawn O. Pearce | b6f3481 | 2007-07-15 01:40:37 -0400 | [diff] [blame] | 1076 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1077 | test_expect_success 'N: copy dirty subdirectory' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1078 | cat >input <<-INPUT_END && |
| 1079 | commit refs/heads/N3 |
| 1080 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1081 | data <<COMMIT |
| 1082 | dirty directory copy |
| 1083 | COMMIT |
| 1084 | |
| 1085 | from refs/heads/branch^0 |
| 1086 | M 644 inline file2/file5 |
| 1087 | data <<EOF |
| 1088 | $file5_data |
| 1089 | EOF |
| 1090 | |
| 1091 | C file2 file3 |
| 1092 | D file2/file5 |
| 1093 | |
| 1094 | INPUT_END |
| 1095 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1096 | git fast-import <input && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1097 | test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree}) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1098 | ' |
Shawn O. Pearce | b6f3481 | 2007-07-15 01:40:37 -0400 | [diff] [blame] | 1099 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1100 | test_expect_success 'N: copy directory by id' ' |
| 1101 | cat >expect <<-\EOF && |
Jonathan Nieder | 334fba6 | 2010-06-30 22:18:19 -0500 | [diff] [blame] | 1102 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf |
| 1103 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf |
| 1104 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1105 | subdir=$(git rev-parse refs/heads/branch^0:file2) && |
| 1106 | cat >input <<-INPUT_END && |
Jonathan Nieder | 334fba6 | 2010-06-30 22:18:19 -0500 | [diff] [blame] | 1107 | commit refs/heads/N4 |
| 1108 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1109 | data <<COMMIT |
| 1110 | copy by tree hash |
| 1111 | COMMIT |
| 1112 | |
| 1113 | from refs/heads/branch^0 |
| 1114 | M 040000 $subdir file3 |
| 1115 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1116 | git fast-import <input && |
| 1117 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && |
| 1118 | compare_diff_raw expect actual |
| 1119 | ' |
Jonathan Nieder | 334fba6 | 2010-06-30 22:18:19 -0500 | [diff] [blame] | 1120 | |
David Barr | 8dc6a37 | 2010-12-02 21:40:20 +1100 | [diff] [blame] | 1121 | test_expect_success PIPE 'N: read and copy directory' ' |
Jeff King | 99094a7 | 2015-03-20 06:07:15 -0400 | [diff] [blame] | 1122 | cat >expect <<-\EOF && |
David Barr | 8dc6a37 | 2010-12-02 21:40:20 +1100 | [diff] [blame] | 1123 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf |
| 1124 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf |
| 1125 | EOF |
| 1126 | git update-ref -d refs/heads/N4 && |
| 1127 | rm -f backflow && |
| 1128 | mkfifo backflow && |
| 1129 | ( |
| 1130 | exec <backflow && |
| 1131 | cat <<-EOF && |
| 1132 | commit refs/heads/N4 |
| 1133 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1134 | data <<COMMIT |
| 1135 | copy by tree hash, part 2 |
| 1136 | COMMIT |
| 1137 | |
| 1138 | from refs/heads/branch^0 |
| 1139 | ls "file2" |
| 1140 | EOF |
| 1141 | read mode type tree filename && |
| 1142 | echo "M 040000 $tree file3" |
| 1143 | ) | |
| 1144 | git fast-import --cat-blob-fd=3 3>backflow && |
| 1145 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && |
| 1146 | compare_diff_raw expect actual |
| 1147 | ' |
| 1148 | |
| 1149 | test_expect_success PIPE 'N: empty directory reads as missing' ' |
| 1150 | cat <<-\EOF >expect && |
| 1151 | OBJNAME |
| 1152 | :000000 100644 OBJNAME OBJNAME A unrelated |
| 1153 | EOF |
| 1154 | echo "missing src" >expect.response && |
| 1155 | git update-ref -d refs/heads/read-empty && |
| 1156 | rm -f backflow && |
| 1157 | mkfifo backflow && |
| 1158 | ( |
| 1159 | exec <backflow && |
| 1160 | cat <<-EOF && |
| 1161 | commit refs/heads/read-empty |
| 1162 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1163 | data <<COMMIT |
| 1164 | read "empty" (missing) directory |
| 1165 | COMMIT |
| 1166 | |
| 1167 | M 100644 inline src/greeting |
| 1168 | data <<BLOB |
| 1169 | hello |
| 1170 | BLOB |
| 1171 | C src/greeting dst1/non-greeting |
| 1172 | C src/greeting unrelated |
| 1173 | # leave behind "empty" src directory |
| 1174 | D src/greeting |
| 1175 | ls "src" |
| 1176 | EOF |
| 1177 | read -r line && |
| 1178 | printf "%s\n" "$line" >response && |
| 1179 | cat <<-\EOF |
| 1180 | D dst1 |
| 1181 | D dst2 |
| 1182 | EOF |
| 1183 | ) | |
| 1184 | git fast-import --cat-blob-fd=3 3>backflow && |
| 1185 | test_cmp expect.response response && |
| 1186 | git rev-list read-empty | |
| 1187 | git diff-tree -r --root --stdin | |
| 1188 | sed "s/$_x40/OBJNAME/g" >actual && |
| 1189 | test_cmp expect actual |
| 1190 | ' |
| 1191 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1192 | test_expect_success 'N: copy root directory by tree hash' ' |
| 1193 | cat >expect <<-\EOF && |
David Barr | 2794ad5 | 2010-10-10 14:30:15 +1100 | [diff] [blame] | 1194 | :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf |
| 1195 | :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf |
| 1196 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1197 | root=$(git rev-parse refs/heads/branch^0^{tree}) && |
| 1198 | cat >input <<-INPUT_END && |
David Barr | 2794ad5 | 2010-10-10 14:30:15 +1100 | [diff] [blame] | 1199 | commit refs/heads/N6 |
| 1200 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1201 | data <<COMMIT |
| 1202 | copy root directory by tree hash |
| 1203 | COMMIT |
| 1204 | |
| 1205 | from refs/heads/branch^0 |
| 1206 | M 040000 $root "" |
| 1207 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1208 | git fast-import <input && |
| 1209 | git diff-tree -C --find-copies-harder -r N4 N6 >actual && |
| 1210 | compare_diff_raw expect actual |
| 1211 | ' |
David Barr | 2794ad5 | 2010-10-10 14:30:15 +1100 | [diff] [blame] | 1212 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1213 | test_expect_success 'N: copy root by path' ' |
| 1214 | cat >expect <<-\EOF && |
John Keeping | aca7061 | 2013-06-23 15:58:19 +0100 | [diff] [blame] | 1215 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf |
| 1216 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf |
| 1217 | :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4 |
| 1218 | :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh |
| 1219 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting |
| 1220 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1221 | cat >input <<-INPUT_END && |
John Keeping | aca7061 | 2013-06-23 15:58:19 +0100 | [diff] [blame] | 1222 | commit refs/heads/N-copy-root-path |
| 1223 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1224 | data <<COMMIT |
| 1225 | copy root directory by (empty) path |
| 1226 | COMMIT |
| 1227 | |
| 1228 | from refs/heads/branch^0 |
| 1229 | C "" oldroot |
| 1230 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1231 | git fast-import <input && |
| 1232 | git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual && |
| 1233 | compare_diff_raw expect actual |
| 1234 | ' |
John Keeping | aca7061 | 2013-06-23 15:58:19 +0100 | [diff] [blame] | 1235 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1236 | test_expect_success 'N: delete directory by copying' ' |
| 1237 | cat >expect <<-\EOF && |
Jonathan Nieder | 8fe533f | 2011-01-27 00:07:49 -0600 | [diff] [blame] | 1238 | OBJID |
| 1239 | :100644 000000 OBJID OBJID D foo/bar/qux |
| 1240 | OBJID |
| 1241 | :000000 100644 OBJID OBJID A foo/bar/baz |
| 1242 | :000000 100644 OBJID OBJID A foo/bar/qux |
| 1243 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1244 | empty_tree=$(git mktree </dev/null) && |
| 1245 | cat >input <<-INPUT_END && |
Jonathan Nieder | 8fe533f | 2011-01-27 00:07:49 -0600 | [diff] [blame] | 1246 | commit refs/heads/N-delete |
| 1247 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1248 | data <<COMMIT |
| 1249 | collect data to be deleted |
| 1250 | COMMIT |
| 1251 | |
| 1252 | deleteall |
| 1253 | M 100644 inline foo/bar/baz |
| 1254 | data <<DATA_END |
| 1255 | hello |
| 1256 | DATA_END |
| 1257 | C "foo/bar/baz" "foo/bar/qux" |
| 1258 | C "foo/bar/baz" "foo/bar/quux/1" |
| 1259 | C "foo/bar/baz" "foo/bar/quuux" |
| 1260 | M 040000 $empty_tree foo/bar/quux |
| 1261 | M 040000 $empty_tree foo/bar/quuux |
| 1262 | |
| 1263 | commit refs/heads/N-delete |
| 1264 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1265 | data <<COMMIT |
| 1266 | delete subdirectory |
| 1267 | COMMIT |
| 1268 | |
| 1269 | M 040000 $empty_tree foo/bar/qux |
| 1270 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1271 | git fast-import <input && |
| 1272 | git rev-list N-delete | |
Jonathan Nieder | 8fe533f | 2011-01-27 00:07:49 -0600 | [diff] [blame] | 1273 | git diff-tree -r --stdin --root --always | |
| 1274 | sed -e "s/$_x40/OBJID/g" >actual && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1275 | test_cmp expect actual |
| 1276 | ' |
Jonathan Nieder | 8fe533f | 2011-01-27 00:07:49 -0600 | [diff] [blame] | 1277 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1278 | test_expect_success 'N: modify copied tree' ' |
| 1279 | cat >expect <<-\EOF && |
Jonathan Nieder | 334fba6 | 2010-06-30 22:18:19 -0500 | [diff] [blame] | 1280 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 |
| 1281 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf |
| 1282 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf |
| 1283 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1284 | subdir=$(git rev-parse refs/heads/branch^0:file2) && |
| 1285 | cat >input <<-INPUT_END && |
Jonathan Nieder | 334fba6 | 2010-06-30 22:18:19 -0500 | [diff] [blame] | 1286 | commit refs/heads/N5 |
| 1287 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1288 | data <<COMMIT |
| 1289 | copy by tree hash |
| 1290 | COMMIT |
| 1291 | |
| 1292 | from refs/heads/branch^0 |
| 1293 | M 040000 $subdir file3 |
| 1294 | |
| 1295 | commit refs/heads/N5 |
| 1296 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1297 | data <<COMMIT |
| 1298 | modify directory copy |
| 1299 | COMMIT |
| 1300 | |
| 1301 | M 644 inline file3/file5 |
| 1302 | data <<EOF |
| 1303 | $file5_data |
| 1304 | EOF |
| 1305 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1306 | git fast-import <input && |
| 1307 | git diff-tree -C --find-copies-harder -r N5^^ N5 >actual && |
| 1308 | compare_diff_raw expect actual |
| 1309 | ' |
Jonathan Nieder | 334fba6 | 2010-06-30 22:18:19 -0500 | [diff] [blame] | 1310 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1311 | test_expect_success 'N: reject foo/ syntax' ' |
| 1312 | subdir=$(git rev-parse refs/heads/branch^0:file2) && |
| 1313 | test_must_fail git fast-import <<-INPUT_END |
Jonathan Nieder | 3421578 | 2010-10-17 20:08:53 -0500 | [diff] [blame] | 1314 | commit refs/heads/N5B |
| 1315 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1316 | data <<COMMIT |
| 1317 | copy with invalid syntax |
| 1318 | COMMIT |
| 1319 | |
| 1320 | from refs/heads/branch^0 |
| 1321 | M 040000 $subdir file3/ |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1322 | INPUT_END |
| 1323 | ' |
Jonathan Nieder | 3421578 | 2010-10-17 20:08:53 -0500 | [diff] [blame] | 1324 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1325 | test_expect_success 'N: reject foo/ syntax in copy source' ' |
| 1326 | test_must_fail git fast-import <<-INPUT_END |
Jonathan Nieder | 178e1de | 2012-03-09 22:07:22 -0600 | [diff] [blame] | 1327 | commit refs/heads/N5C |
| 1328 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1329 | data <<COMMIT |
| 1330 | copy with invalid syntax |
| 1331 | COMMIT |
| 1332 | |
| 1333 | from refs/heads/branch^0 |
| 1334 | C file2/ file3 |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1335 | INPUT_END |
| 1336 | ' |
Jonathan Nieder | 178e1de | 2012-03-09 22:07:22 -0600 | [diff] [blame] | 1337 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1338 | test_expect_success 'N: reject foo/ syntax in rename source' ' |
| 1339 | test_must_fail git fast-import <<-INPUT_END |
Jonathan Nieder | 178e1de | 2012-03-09 22:07:22 -0600 | [diff] [blame] | 1340 | commit refs/heads/N5D |
| 1341 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1342 | data <<COMMIT |
| 1343 | rename with invalid syntax |
| 1344 | COMMIT |
| 1345 | |
| 1346 | from refs/heads/branch^0 |
| 1347 | R file2/ file3 |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1348 | INPUT_END |
| 1349 | ' |
Jonathan Nieder | 178e1de | 2012-03-09 22:07:22 -0600 | [diff] [blame] | 1350 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1351 | test_expect_success 'N: reject foo/ syntax in ls argument' ' |
| 1352 | test_must_fail git fast-import <<-INPUT_END |
Jonathan Nieder | 178e1de | 2012-03-09 22:07:22 -0600 | [diff] [blame] | 1353 | commit refs/heads/N5E |
| 1354 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1355 | data <<COMMIT |
| 1356 | copy with invalid syntax |
| 1357 | COMMIT |
| 1358 | |
| 1359 | from refs/heads/branch^0 |
| 1360 | ls "file2/" |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1361 | INPUT_END |
| 1362 | ' |
Jonathan Nieder | 178e1de | 2012-03-09 22:07:22 -0600 | [diff] [blame] | 1363 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1364 | test_expect_success 'N: copy to root by id and modify' ' |
| 1365 | echo "hello, world" >expect.foo && |
| 1366 | echo hello >expect.bar && |
| 1367 | git fast-import <<-SETUP_END && |
Jonathan Nieder | 5edde51 | 2010-10-17 20:03:38 -0500 | [diff] [blame] | 1368 | commit refs/heads/N7 |
| 1369 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1370 | data <<COMMIT |
| 1371 | hello, tree |
| 1372 | COMMIT |
| 1373 | |
| 1374 | deleteall |
| 1375 | M 644 inline foo/bar |
| 1376 | data <<EOF |
| 1377 | hello |
| 1378 | EOF |
| 1379 | SETUP_END |
| 1380 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1381 | tree=$(git rev-parse --verify N7:) && |
| 1382 | git fast-import <<-INPUT_END && |
Jonathan Nieder | 5edde51 | 2010-10-17 20:03:38 -0500 | [diff] [blame] | 1383 | commit refs/heads/N8 |
| 1384 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1385 | data <<COMMIT |
| 1386 | copy to root by id and modify |
| 1387 | COMMIT |
| 1388 | |
| 1389 | M 040000 $tree "" |
| 1390 | M 644 inline foo/foo |
| 1391 | data <<EOF |
| 1392 | hello, world |
| 1393 | EOF |
| 1394 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1395 | git show N8:foo/foo >actual.foo && |
| 1396 | git show N8:foo/bar >actual.bar && |
| 1397 | test_cmp expect.foo actual.foo && |
| 1398 | test_cmp expect.bar actual.bar |
| 1399 | ' |
Jonathan Nieder | 5edde51 | 2010-10-17 20:03:38 -0500 | [diff] [blame] | 1400 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1401 | test_expect_success 'N: extract subtree' ' |
| 1402 | branch=$(git rev-parse --verify refs/heads/branch^{tree}) && |
| 1403 | cat >input <<-INPUT_END && |
Jonathan Nieder | 3421578 | 2010-10-17 20:08:53 -0500 | [diff] [blame] | 1404 | commit refs/heads/N9 |
| 1405 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1406 | data <<COMMIT |
| 1407 | extract subtree branch:newdir |
| 1408 | COMMIT |
| 1409 | |
| 1410 | M 040000 $branch "" |
Jonathan Nieder | 971728c | 2010-10-17 20:44:04 -0500 | [diff] [blame] | 1411 | C "newdir" "" |
Jonathan Nieder | 3421578 | 2010-10-17 20:08:53 -0500 | [diff] [blame] | 1412 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1413 | git fast-import <input && |
| 1414 | git diff --exit-code branch:newdir N9 |
| 1415 | ' |
Jonathan Nieder | 3421578 | 2010-10-17 20:08:53 -0500 | [diff] [blame] | 1416 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1417 | test_expect_success 'N: modify subtree, extract it, and modify again' ' |
| 1418 | echo hello >expect.baz && |
| 1419 | echo hello, world >expect.qux && |
| 1420 | git fast-import <<-SETUP_END && |
Jonathan Nieder | 971728c | 2010-10-17 20:44:04 -0500 | [diff] [blame] | 1421 | commit refs/heads/N10 |
| 1422 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1423 | data <<COMMIT |
| 1424 | hello, tree |
| 1425 | COMMIT |
| 1426 | |
| 1427 | deleteall |
| 1428 | M 644 inline foo/bar/baz |
| 1429 | data <<EOF |
| 1430 | hello |
| 1431 | EOF |
| 1432 | SETUP_END |
| 1433 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1434 | tree=$(git rev-parse --verify N10:) && |
| 1435 | git fast-import <<-INPUT_END && |
Jonathan Nieder | 971728c | 2010-10-17 20:44:04 -0500 | [diff] [blame] | 1436 | commit refs/heads/N11 |
| 1437 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1438 | data <<COMMIT |
| 1439 | copy to root by id and modify |
| 1440 | COMMIT |
| 1441 | |
| 1442 | M 040000 $tree "" |
| 1443 | M 100644 inline foo/bar/qux |
| 1444 | data <<EOF |
| 1445 | hello, world |
| 1446 | EOF |
| 1447 | R "foo" "" |
| 1448 | C "bar/qux" "bar/quux" |
| 1449 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1450 | git show N11:bar/baz >actual.baz && |
| 1451 | git show N11:bar/qux >actual.qux && |
| 1452 | git show N11:bar/quux >actual.quux && |
| 1453 | test_cmp expect.baz actual.baz && |
| 1454 | test_cmp expect.qux actual.qux && |
| 1455 | test_cmp expect.qux actual.quux' |
Jonathan Nieder | 971728c | 2010-10-17 20:44:04 -0500 | [diff] [blame] | 1456 | |
Shawn O. Pearce | 401d53f | 2007-08-01 00:05:15 -0400 | [diff] [blame] | 1457 | ### |
| 1458 | ### series O |
| 1459 | ### |
| 1460 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1461 | test_expect_success 'O: comments are all skipped' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1462 | cat >input <<-INPUT_END && |
| 1463 | #we will |
| 1464 | commit refs/heads/O1 |
| 1465 | # -- ignore all of this text |
| 1466 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1467 | # $GIT_COMMITTER_NAME has inserted here for his benefit. |
| 1468 | data <<COMMIT |
| 1469 | dirty directory copy |
| 1470 | COMMIT |
| 1471 | |
| 1472 | # do not forget the import blank line! |
| 1473 | # |
| 1474 | # yes, we started from our usual base of branch^0. |
| 1475 | # i like branch^0. |
| 1476 | from refs/heads/branch^0 |
| 1477 | # and we need to reuse file2/file5 from N3 above. |
| 1478 | M 644 inline file2/file5 |
| 1479 | # otherwise the tree will be different |
| 1480 | data <<EOF |
| 1481 | $file5_data |
| 1482 | EOF |
| 1483 | |
| 1484 | # do not forget to copy file2 to file3 |
| 1485 | C file2 file3 |
| 1486 | # |
| 1487 | # or to delete file5 from file2. |
| 1488 | D file2/file5 |
| 1489 | # are we done yet? |
| 1490 | |
| 1491 | INPUT_END |
| 1492 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1493 | git fast-import <input && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1494 | test $(git rev-parse N3) = $(git rev-parse O1) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1495 | ' |
Shawn O. Pearce | 401d53f | 2007-08-01 00:05:15 -0400 | [diff] [blame] | 1496 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1497 | test_expect_success 'O: blank lines not necessary after data commands' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1498 | cat >input <<-INPUT_END && |
| 1499 | commit refs/heads/O2 |
| 1500 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1501 | data <<COMMIT |
| 1502 | dirty directory copy |
| 1503 | COMMIT |
| 1504 | from refs/heads/branch^0 |
| 1505 | M 644 inline file2/file5 |
| 1506 | data <<EOF |
| 1507 | $file5_data |
| 1508 | EOF |
| 1509 | C file2 file3 |
| 1510 | D file2/file5 |
| 1511 | |
| 1512 | INPUT_END |
| 1513 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1514 | git fast-import <input && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1515 | test $(git rev-parse N3) = $(git rev-parse O2) |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1516 | ' |
Shawn O. Pearce | 2c570cd | 2007-08-01 00:24:25 -0400 | [diff] [blame] | 1517 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1518 | test_expect_success 'O: repack before next test' ' |
| 1519 | git repack -a -d |
| 1520 | ' |
Shawn O. Pearce | 1fdb649 | 2007-08-01 02:22:53 -0400 | [diff] [blame] | 1521 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1522 | test_expect_success 'O: blank lines not necessary after other commands' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1523 | cat >input <<-INPUT_END && |
| 1524 | commit refs/heads/O3 |
| 1525 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1526 | data <<COMMIT |
| 1527 | zstring |
| 1528 | COMMIT |
| 1529 | commit refs/heads/O3 |
| 1530 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1531 | data <<COMMIT |
| 1532 | zof |
| 1533 | COMMIT |
| 1534 | checkpoint |
| 1535 | commit refs/heads/O3 |
| 1536 | mark :5 |
| 1537 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1538 | data <<COMMIT |
| 1539 | zempty |
| 1540 | COMMIT |
| 1541 | checkpoint |
| 1542 | commit refs/heads/O3 |
| 1543 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1544 | data <<COMMIT |
| 1545 | zcommits |
| 1546 | COMMIT |
| 1547 | reset refs/tags/O3-2nd |
| 1548 | from :5 |
| 1549 | reset refs/tags/O3-3rd |
| 1550 | from :5 |
| 1551 | INPUT_END |
| 1552 | |
| 1553 | cat >expect <<-INPUT_END && |
| 1554 | string |
| 1555 | of |
| 1556 | empty |
| 1557 | commits |
| 1558 | INPUT_END |
| 1559 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1560 | git fast-import <input && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1561 | test 8 = $(find .git/objects/pack -type f | wc -l) && |
| 1562 | test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1563 | git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && |
| 1564 | test_cmp expect actual |
| 1565 | ' |
Shawn O. Pearce | 1fdb649 | 2007-08-01 02:22:53 -0400 | [diff] [blame] | 1566 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1567 | test_expect_success 'O: progress outputs as requested by input' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1568 | cat >input <<-INPUT_END && |
| 1569 | commit refs/heads/O4 |
| 1570 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1571 | data <<COMMIT |
| 1572 | zstring |
| 1573 | COMMIT |
| 1574 | commit refs/heads/O4 |
| 1575 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1576 | data <<COMMIT |
| 1577 | zof |
| 1578 | COMMIT |
| 1579 | progress Two commits down, 2 to go! |
| 1580 | commit refs/heads/O4 |
| 1581 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1582 | data <<COMMIT |
| 1583 | zempty |
| 1584 | COMMIT |
| 1585 | progress Three commits down, 1 to go! |
| 1586 | commit refs/heads/O4 |
| 1587 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1588 | data <<COMMIT |
| 1589 | zcommits |
| 1590 | COMMIT |
| 1591 | progress done! |
| 1592 | INPUT_END |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1593 | git fast-import <input >actual && |
| 1594 | grep "progress " <input >expect && |
| 1595 | test_cmp expect actual |
| 1596 | ' |
Shawn O. Pearce | ac053c0 | 2007-08-01 10:23:08 -0400 | [diff] [blame] | 1597 | |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1598 | ### |
| 1599 | ### series P (gitlinks) |
| 1600 | ### |
| 1601 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1602 | test_expect_success 'P: superproject & submodule mix' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1603 | cat >input <<-INPUT_END && |
| 1604 | blob |
| 1605 | mark :1 |
| 1606 | data 10 |
| 1607 | test file |
| 1608 | |
| 1609 | reset refs/heads/sub |
| 1610 | commit refs/heads/sub |
| 1611 | mark :2 |
| 1612 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1613 | data 12 |
| 1614 | sub_initial |
| 1615 | M 100644 :1 file |
| 1616 | |
| 1617 | blob |
| 1618 | mark :3 |
| 1619 | data <<DATAEND |
| 1620 | [submodule "sub"] |
| 1621 | path = sub |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1622 | url = "$(pwd)/sub" |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1623 | DATAEND |
| 1624 | |
| 1625 | commit refs/heads/subuse1 |
| 1626 | mark :4 |
| 1627 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1628 | data 8 |
| 1629 | initial |
| 1630 | from refs/heads/master |
| 1631 | M 100644 :3 .gitmodules |
| 1632 | M 160000 :2 sub |
| 1633 | |
| 1634 | blob |
| 1635 | mark :5 |
| 1636 | data 20 |
| 1637 | test file |
| 1638 | more data |
| 1639 | |
| 1640 | commit refs/heads/sub |
| 1641 | mark :6 |
| 1642 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1643 | data 11 |
| 1644 | sub_second |
| 1645 | from :2 |
| 1646 | M 100644 :5 file |
| 1647 | |
| 1648 | commit refs/heads/subuse1 |
| 1649 | mark :7 |
| 1650 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1651 | data 7 |
| 1652 | second |
| 1653 | from :4 |
| 1654 | M 160000 :6 sub |
| 1655 | |
| 1656 | INPUT_END |
| 1657 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1658 | git fast-import <input && |
| 1659 | git checkout subuse1 && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1660 | rm -rf sub && |
| 1661 | mkdir sub && |
| 1662 | ( |
| 1663 | cd sub && |
| 1664 | git init && |
| 1665 | git fetch --update-head-ok .. refs/heads/sub:refs/heads/master && |
| 1666 | git checkout master |
| 1667 | ) && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1668 | git submodule init && |
| 1669 | git submodule update |
| 1670 | ' |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1671 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1672 | test_expect_success 'P: verbatim SHA gitlinks' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1673 | SUBLAST=$(git rev-parse --verify sub) && |
| 1674 | SUBPREV=$(git rev-parse --verify sub^) && |
| 1675 | |
| 1676 | cat >input <<-INPUT_END && |
| 1677 | blob |
| 1678 | mark :1 |
| 1679 | data <<DATAEND |
| 1680 | [submodule "sub"] |
| 1681 | path = sub |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1682 | url = "$(pwd)/sub" |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1683 | DATAEND |
| 1684 | |
| 1685 | commit refs/heads/subuse2 |
| 1686 | mark :2 |
| 1687 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1688 | data 8 |
| 1689 | initial |
| 1690 | from refs/heads/master |
| 1691 | M 100644 :1 .gitmodules |
| 1692 | M 160000 $SUBPREV sub |
| 1693 | |
| 1694 | commit refs/heads/subuse2 |
| 1695 | mark :3 |
| 1696 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1697 | data 7 |
| 1698 | second |
| 1699 | from :2 |
| 1700 | M 160000 $SUBLAST sub |
| 1701 | |
| 1702 | INPUT_END |
| 1703 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1704 | git branch -D sub && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1705 | git gc && |
| 1706 | git prune && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1707 | git fast-import <input && |
| 1708 | test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1) |
| 1709 | ' |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1710 | |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1711 | test_expect_success 'P: fail on inline gitlink' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1712 | test_tick && |
| 1713 | cat >input <<-INPUT_END && |
| 1714 | commit refs/heads/subuse3 |
| 1715 | mark :1 |
| 1716 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1717 | data <<COMMIT |
| 1718 | corrupt |
| 1719 | COMMIT |
| 1720 | |
| 1721 | from refs/heads/subuse2 |
| 1722 | M 160000 inline sub |
| 1723 | data <<DATA |
| 1724 | $SUBPREV |
| 1725 | DATA |
| 1726 | |
| 1727 | INPUT_END |
| 1728 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1729 | test_must_fail git fast-import <input |
| 1730 | ' |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1731 | |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1732 | test_expect_success 'P: fail on blob mark in gitlink' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1733 | test_tick && |
| 1734 | cat >input <<-INPUT_END && |
| 1735 | blob |
| 1736 | mark :1 |
| 1737 | data <<DATA |
| 1738 | $SUBPREV |
| 1739 | DATA |
| 1740 | |
| 1741 | commit refs/heads/subuse3 |
| 1742 | mark :2 |
| 1743 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1744 | data <<COMMIT |
| 1745 | corrupt |
| 1746 | COMMIT |
| 1747 | |
| 1748 | from refs/heads/subuse2 |
| 1749 | M 160000 :1 sub |
| 1750 | |
| 1751 | INPUT_END |
| 1752 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1753 | test_must_fail git fast-import <input |
| 1754 | ' |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 1755 | |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1756 | ### |
| 1757 | ### series Q (notes) |
| 1758 | ### |
| 1759 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1760 | test_expect_success 'Q: commit notes' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1761 | note1_data="The first note for the first commit" && |
| 1762 | note2_data="The first note for the second commit" && |
| 1763 | note3_data="The first note for the third commit" && |
| 1764 | note1b_data="The second note for the first commit" && |
| 1765 | note1c_data="The third note for the first commit" && |
| 1766 | note2b_data="The second note for the second commit" && |
| 1767 | |
| 1768 | test_tick && |
| 1769 | cat >input <<-INPUT_END && |
| 1770 | blob |
| 1771 | mark :2 |
| 1772 | data <<EOF |
| 1773 | $file2_data |
| 1774 | EOF |
| 1775 | |
| 1776 | commit refs/heads/notes-test |
| 1777 | mark :3 |
| 1778 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1779 | data <<COMMIT |
| 1780 | first (:3) |
| 1781 | COMMIT |
| 1782 | |
| 1783 | M 644 :2 file2 |
| 1784 | |
| 1785 | blob |
| 1786 | mark :4 |
| 1787 | data $file4_len |
| 1788 | $file4_data |
| 1789 | commit refs/heads/notes-test |
| 1790 | mark :5 |
| 1791 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1792 | data <<COMMIT |
| 1793 | second (:5) |
| 1794 | COMMIT |
| 1795 | |
| 1796 | M 644 :4 file4 |
| 1797 | |
| 1798 | commit refs/heads/notes-test |
| 1799 | mark :6 |
| 1800 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1801 | data <<COMMIT |
| 1802 | third (:6) |
| 1803 | COMMIT |
| 1804 | |
| 1805 | M 644 inline file5 |
| 1806 | data <<EOF |
| 1807 | $file5_data |
| 1808 | EOF |
| 1809 | |
| 1810 | M 755 inline file6 |
| 1811 | data <<EOF |
| 1812 | $file6_data |
| 1813 | EOF |
| 1814 | |
| 1815 | blob |
| 1816 | mark :7 |
| 1817 | data <<EOF |
| 1818 | $note1_data |
| 1819 | EOF |
| 1820 | |
| 1821 | blob |
| 1822 | mark :8 |
| 1823 | data <<EOF |
| 1824 | $note2_data |
| 1825 | EOF |
| 1826 | |
| 1827 | commit refs/notes/foobar |
| 1828 | mark :9 |
| 1829 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1830 | data <<COMMIT |
| 1831 | notes (:9) |
| 1832 | COMMIT |
| 1833 | |
| 1834 | N :7 :3 |
| 1835 | N :8 :5 |
| 1836 | N inline :6 |
| 1837 | data <<EOF |
| 1838 | $note3_data |
| 1839 | EOF |
| 1840 | |
| 1841 | commit refs/notes/foobar |
| 1842 | mark :10 |
| 1843 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1844 | data <<COMMIT |
| 1845 | notes (:10) |
| 1846 | COMMIT |
| 1847 | |
| 1848 | N inline :3 |
| 1849 | data <<EOF |
| 1850 | $note1b_data |
| 1851 | EOF |
| 1852 | |
| 1853 | commit refs/notes/foobar2 |
| 1854 | mark :11 |
| 1855 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1856 | data <<COMMIT |
| 1857 | notes (:11) |
| 1858 | COMMIT |
| 1859 | |
| 1860 | N inline :3 |
| 1861 | data <<EOF |
| 1862 | $note1c_data |
| 1863 | EOF |
| 1864 | |
| 1865 | commit refs/notes/foobar |
| 1866 | mark :12 |
| 1867 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1868 | data <<COMMIT |
| 1869 | notes (:12) |
| 1870 | COMMIT |
| 1871 | |
| 1872 | deleteall |
| 1873 | N inline :5 |
| 1874 | data <<EOF |
| 1875 | $note2b_data |
| 1876 | EOF |
| 1877 | |
| 1878 | INPUT_END |
| 1879 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1880 | git fast-import <input && |
| 1881 | git whatchanged notes-test |
| 1882 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 1883 | |
| 1884 | test_expect_success 'Q: verify pack' ' |
| 1885 | verify_packs |
| 1886 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1887 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1888 | test_expect_success 'Q: verify first commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1889 | commit1=$(git rev-parse notes-test~2) && |
| 1890 | commit2=$(git rev-parse notes-test^) && |
| 1891 | commit3=$(git rev-parse notes-test) && |
| 1892 | |
| 1893 | cat >expect <<-EOF && |
| 1894 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1895 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1896 | |
| 1897 | first (:3) |
| 1898 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1899 | git cat-file commit notes-test~2 | sed 1d >actual && |
| 1900 | test_cmp expect actual |
| 1901 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1902 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1903 | test_expect_success 'Q: verify second commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1904 | cat >expect <<-EOF && |
| 1905 | parent $commit1 |
| 1906 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1907 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1908 | |
| 1909 | second (:5) |
| 1910 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1911 | git cat-file commit notes-test^ | sed 1d >actual && |
| 1912 | test_cmp expect actual |
| 1913 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1914 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1915 | test_expect_success 'Q: verify third commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1916 | cat >expect <<-EOF && |
| 1917 | parent $commit2 |
| 1918 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1919 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1920 | |
| 1921 | third (:6) |
| 1922 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1923 | git cat-file commit notes-test | sed 1d >actual && |
| 1924 | test_cmp expect actual |
| 1925 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1926 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1927 | test_expect_success 'Q: verify first notes commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1928 | cat >expect <<-EOF && |
| 1929 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1930 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1931 | |
| 1932 | notes (:9) |
| 1933 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1934 | git cat-file commit refs/notes/foobar~2 | sed 1d >actual && |
| 1935 | test_cmp expect actual |
| 1936 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1937 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1938 | test_expect_success 'Q: verify first notes tree' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1939 | cat >expect.unsorted <<-EOF && |
| 1940 | 100644 blob $commit1 |
| 1941 | 100644 blob $commit2 |
| 1942 | 100644 blob $commit3 |
| 1943 | EOF |
| 1944 | cat expect.unsorted | sort >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1945 | git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 1946 | test_cmp expect actual |
| 1947 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1948 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1949 | test_expect_success 'Q: verify first note for first commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1950 | echo "$note1_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1951 | git cat-file blob refs/notes/foobar~2:$commit1 >actual && |
| 1952 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1953 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1954 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1955 | test_expect_success 'Q: verify first note for second commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1956 | echo "$note2_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1957 | git cat-file blob refs/notes/foobar~2:$commit2 >actual && |
| 1958 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1959 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 1960 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1961 | test_expect_success 'Q: verify first note for third commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1962 | echo "$note3_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1963 | git cat-file blob refs/notes/foobar~2:$commit3 >actual && |
| 1964 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1965 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 1966 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1967 | test_expect_success 'Q: verify second notes commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1968 | cat >expect <<-EOF && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 1969 | parent $(git rev-parse --verify refs/notes/foobar~2) |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1970 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1971 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 1972 | |
| 1973 | notes (:10) |
| 1974 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1975 | git cat-file commit refs/notes/foobar^ | sed 1d >actual && |
| 1976 | test_cmp expect actual |
| 1977 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 1978 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1979 | test_expect_success 'Q: verify second notes tree' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1980 | cat >expect.unsorted <<-EOF && |
| 1981 | 100644 blob $commit1 |
| 1982 | 100644 blob $commit2 |
| 1983 | 100644 blob $commit3 |
| 1984 | EOF |
| 1985 | cat expect.unsorted | sort >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1986 | git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 1987 | test_cmp expect actual |
| 1988 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 1989 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1990 | test_expect_success 'Q: verify second note for first commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1991 | echo "$note1b_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1992 | git cat-file blob refs/notes/foobar^:$commit1 >actual && |
| 1993 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1994 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 1995 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 1996 | test_expect_success 'Q: verify first note for second commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 1997 | echo "$note2_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 1998 | git cat-file blob refs/notes/foobar^:$commit2 >actual && |
| 1999 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2000 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2001 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2002 | test_expect_success 'Q: verify first note for third commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2003 | echo "$note3_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 2004 | git cat-file blob refs/notes/foobar^:$commit3 >actual && |
| 2005 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2006 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2007 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2008 | test_expect_success 'Q: verify third notes commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2009 | cat >expect <<-EOF && |
| 2010 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2011 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2012 | |
| 2013 | notes (:11) |
| 2014 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2015 | git cat-file commit refs/notes/foobar2 | sed 1d >actual && |
| 2016 | test_cmp expect actual |
| 2017 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2018 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2019 | test_expect_success 'Q: verify third notes tree' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2020 | cat >expect.unsorted <<-EOF && |
| 2021 | 100644 blob $commit1 |
| 2022 | EOF |
| 2023 | cat expect.unsorted | sort >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2024 | git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 2025 | test_cmp expect actual |
| 2026 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2027 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2028 | test_expect_success 'Q: verify third note for first commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2029 | echo "$note1c_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 2030 | git cat-file blob refs/notes/foobar2:$commit1 >actual && |
| 2031 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2032 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2033 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2034 | test_expect_success 'Q: verify fourth notes commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2035 | cat >expect <<-EOF && |
Elia Pinto | 80a6b3f | 2016-01-12 11:49:35 +0000 | [diff] [blame] | 2036 | parent $(git rev-parse --verify refs/notes/foobar^) |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2037 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2038 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2039 | |
| 2040 | notes (:12) |
| 2041 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2042 | git cat-file commit refs/notes/foobar | sed 1d >actual && |
| 2043 | test_cmp expect actual |
| 2044 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2045 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2046 | test_expect_success 'Q: verify fourth notes tree' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2047 | cat >expect.unsorted <<-EOF && |
| 2048 | 100644 blob $commit2 |
| 2049 | EOF |
| 2050 | cat expect.unsorted | sort >expect && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2051 | git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
| 2052 | test_cmp expect actual |
| 2053 | ' |
Johan Herland | 2a113ae | 2009-12-07 12:27:24 +0100 | [diff] [blame] | 2054 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2055 | test_expect_success 'Q: verify second note for second commit' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2056 | echo "$note2b_data" >expect && |
Johannes Sixt | ec2c10b | 2015-11-19 20:09:46 +0100 | [diff] [blame] | 2057 | git cat-file blob refs/notes/foobar:$commit2 >actual && |
| 2058 | test_cmp expect actual |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2059 | ' |
Johan Herland | a8dd2e7 | 2009-10-09 12:22:02 +0200 | [diff] [blame] | 2060 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2061 | test_expect_success 'Q: deny note on empty branch' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2062 | cat >input <<-EOF && |
| 2063 | reset refs/heads/Q0 |
| 2064 | |
| 2065 | commit refs/heads/note-Q0 |
| 2066 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2067 | data <<COMMIT |
| 2068 | Note for an empty branch. |
| 2069 | COMMIT |
| 2070 | |
| 2071 | N inline refs/heads/Q0 |
| 2072 | data <<NOTE |
| 2073 | some note |
| 2074 | NOTE |
| 2075 | EOF |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2076 | test_must_fail git fast-import <input |
| 2077 | ' |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2078 | ### |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2079 | ### series R (feature and option) |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2080 | ### |
| 2081 | |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2082 | test_expect_success 'R: abort on unsupported feature' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2083 | cat >input <<-EOF && |
| 2084 | feature no-such-feature-exists |
| 2085 | EOF |
| 2086 | |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2087 | test_must_fail git fast-import <input |
| 2088 | ' |
| 2089 | |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2090 | test_expect_success 'R: supported feature is accepted' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2091 | cat >input <<-EOF && |
| 2092 | feature date-format=now |
| 2093 | EOF |
| 2094 | |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2095 | git fast-import <input |
| 2096 | ' |
| 2097 | |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2098 | test_expect_success 'R: abort on receiving feature after data command' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2099 | cat >input <<-EOF && |
| 2100 | blob |
| 2101 | data 3 |
| 2102 | hi |
| 2103 | feature date-format=now |
| 2104 | EOF |
| 2105 | |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2106 | test_must_fail git fast-import <input |
| 2107 | ' |
| 2108 | |
Sverre Rabbelier | 081751c | 2009-12-04 18:06:59 +0100 | [diff] [blame] | 2109 | test_expect_success 'R: only one import-marks feature allowed per stream' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2110 | cat >input <<-EOF && |
| 2111 | feature import-marks=git.marks |
| 2112 | feature import-marks=git2.marks |
| 2113 | EOF |
| 2114 | |
Sverre Rabbelier | 081751c | 2009-12-04 18:06:59 +0100 | [diff] [blame] | 2115 | test_must_fail git fast-import <input |
| 2116 | ' |
| 2117 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2118 | test_expect_success 'R: export-marks feature results in a marks file being created' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2119 | cat >input <<-EOF && |
| 2120 | feature export-marks=git.marks |
| 2121 | blob |
| 2122 | mark :1 |
| 2123 | data 3 |
| 2124 | hi |
| 2125 | |
| 2126 | EOF |
| 2127 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2128 | cat input | git fast-import && |
| 2129 | grep :1 git.marks |
| 2130 | ' |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2131 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2132 | test_expect_success 'R: export-marks options can be overridden by commandline options' ' |
| 2133 | cat input | git fast-import --export-marks=other.marks && |
| 2134 | grep :1 other.marks |
| 2135 | ' |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2136 | |
Ramkumar Ramachandra | dded4f1 | 2011-01-15 12:01:46 +0530 | [diff] [blame] | 2137 | test_expect_success 'R: catch typo in marks file name' ' |
| 2138 | test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null && |
| 2139 | echo "feature import-marks=nonexistent.marks" | |
| 2140 | test_must_fail git fast-import |
| 2141 | ' |
| 2142 | |
| 2143 | test_expect_success 'R: import and output marks can be the same file' ' |
| 2144 | rm -f io.marks && |
| 2145 | blob=$(echo hi | git hash-object --stdin) && |
| 2146 | cat >expect <<-EOF && |
| 2147 | :1 $blob |
| 2148 | :2 $blob |
| 2149 | EOF |
| 2150 | git fast-import --export-marks=io.marks <<-\EOF && |
| 2151 | blob |
| 2152 | mark :1 |
| 2153 | data 3 |
| 2154 | hi |
| 2155 | |
| 2156 | EOF |
| 2157 | git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && |
| 2158 | blob |
| 2159 | mark :2 |
| 2160 | data 3 |
| 2161 | hi |
| 2162 | |
| 2163 | EOF |
| 2164 | test_cmp expect io.marks |
| 2165 | ' |
| 2166 | |
| 2167 | test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' ' |
| 2168 | rm -f io.marks && |
| 2169 | test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF |
| 2170 | blob |
| 2171 | mark :1 |
| 2172 | data 3 |
| 2173 | hi |
| 2174 | |
| 2175 | EOF |
| 2176 | ' |
| 2177 | |
| 2178 | test_expect_success 'R: --import-marks-if-exists' ' |
| 2179 | rm -f io.marks && |
| 2180 | blob=$(echo hi | git hash-object --stdin) && |
| 2181 | echo ":1 $blob" >expect && |
| 2182 | git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF && |
| 2183 | blob |
| 2184 | mark :1 |
| 2185 | data 3 |
| 2186 | hi |
| 2187 | |
| 2188 | EOF |
| 2189 | test_cmp expect io.marks |
| 2190 | ' |
| 2191 | |
Dmitry Ivankov | 3beb4fc | 2011-08-17 16:42:58 +0600 | [diff] [blame] | 2192 | test_expect_success 'R: feature import-marks-if-exists' ' |
| 2193 | rm -f io.marks && |
| 2194 | >expect && |
| 2195 | |
| 2196 | git fast-import --export-marks=io.marks <<-\EOF && |
| 2197 | feature import-marks-if-exists=not_io.marks |
| 2198 | EOF |
| 2199 | test_cmp expect io.marks && |
| 2200 | |
| 2201 | blob=$(echo hi | git hash-object --stdin) && |
| 2202 | |
| 2203 | echo ":1 $blob" >io.marks && |
| 2204 | echo ":1 $blob" >expect && |
| 2205 | echo ":2 $blob" >>expect && |
| 2206 | |
| 2207 | git fast-import --export-marks=io.marks <<-\EOF && |
| 2208 | feature import-marks-if-exists=io.marks |
| 2209 | blob |
| 2210 | mark :2 |
| 2211 | data 3 |
| 2212 | hi |
| 2213 | |
| 2214 | EOF |
| 2215 | test_cmp expect io.marks && |
| 2216 | |
| 2217 | echo ":3 $blob" >>expect && |
| 2218 | |
| 2219 | git fast-import --import-marks=io.marks \ |
| 2220 | --export-marks=io.marks <<-\EOF && |
| 2221 | feature import-marks-if-exists=not_io.marks |
| 2222 | blob |
| 2223 | mark :3 |
| 2224 | data 3 |
| 2225 | hi |
| 2226 | |
| 2227 | EOF |
| 2228 | test_cmp expect io.marks && |
| 2229 | |
| 2230 | >expect && |
| 2231 | |
| 2232 | git fast-import --import-marks-if-exists=not_io.marks \ |
Jeff King | 8fb2687 | 2015-03-20 06:06:15 -0400 | [diff] [blame] | 2233 | --export-marks=io.marks <<-\EOF && |
Dmitry Ivankov | 3beb4fc | 2011-08-17 16:42:58 +0600 | [diff] [blame] | 2234 | feature import-marks-if-exists=io.marks |
| 2235 | EOF |
| 2236 | test_cmp expect io.marks |
| 2237 | ' |
| 2238 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2239 | test_expect_success 'R: import to output marks works without any content' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2240 | cat >input <<-EOF && |
| 2241 | feature import-marks=marks.out |
| 2242 | feature export-marks=marks.new |
| 2243 | EOF |
| 2244 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2245 | cat input | git fast-import && |
| 2246 | test_cmp marks.out marks.new |
| 2247 | ' |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2248 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2249 | test_expect_success 'R: import marks prefers commandline marks file over the stream' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2250 | cat >input <<-EOF && |
| 2251 | feature import-marks=nonexistent.marks |
| 2252 | feature export-marks=marks.new |
| 2253 | EOF |
| 2254 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2255 | cat input | git fast-import --import-marks=marks.out && |
| 2256 | test_cmp marks.out marks.new |
| 2257 | ' |
Sverre Rabbelier | f963bd5 | 2009-12-04 18:06:56 +0100 | [diff] [blame] | 2258 | |
Sverre Rabbelier | 081751c | 2009-12-04 18:06:59 +0100 | [diff] [blame] | 2259 | |
Sverre Rabbelier | 081751c | 2009-12-04 18:06:59 +0100 | [diff] [blame] | 2260 | test_expect_success 'R: multiple --import-marks= should be honoured' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2261 | cat >input <<-EOF && |
| 2262 | feature import-marks=nonexistent.marks |
| 2263 | feature export-marks=combined.marks |
| 2264 | EOF |
| 2265 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2266 | head -n2 marks.out > one.marks && |
| 2267 | tail -n +3 marks.out > two.marks && |
| 2268 | git fast-import --import-marks=one.marks --import-marks=two.marks <input && |
| 2269 | test_cmp marks.out combined.marks |
Sverre Rabbelier | 081751c | 2009-12-04 18:06:59 +0100 | [diff] [blame] | 2270 | ' |
| 2271 | |
Sverre Rabbelier | bc3c79a | 2009-12-04 18:07:00 +0100 | [diff] [blame] | 2272 | test_expect_success 'R: feature relative-marks should be honoured' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2273 | cat >input <<-EOF && |
| 2274 | feature relative-marks |
| 2275 | feature import-marks=relative.in |
| 2276 | feature export-marks=relative.out |
| 2277 | EOF |
| 2278 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2279 | mkdir -p .git/info/fast-import/ && |
| 2280 | cp marks.new .git/info/fast-import/relative.in && |
| 2281 | git fast-import <input && |
| 2282 | test_cmp marks.new .git/info/fast-import/relative.out |
Sverre Rabbelier | bc3c79a | 2009-12-04 18:07:00 +0100 | [diff] [blame] | 2283 | ' |
| 2284 | |
Sverre Rabbelier | bc3c79a | 2009-12-04 18:07:00 +0100 | [diff] [blame] | 2285 | test_expect_success 'R: feature no-relative-marks should be honoured' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2286 | cat >input <<-EOF && |
| 2287 | feature relative-marks |
| 2288 | feature import-marks=relative.in |
| 2289 | feature no-relative-marks |
| 2290 | feature export-marks=non-relative.out |
| 2291 | EOF |
| 2292 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2293 | git fast-import <input && |
| 2294 | test_cmp marks.new non-relative.out |
Sverre Rabbelier | bc3c79a | 2009-12-04 18:07:00 +0100 | [diff] [blame] | 2295 | ' |
| 2296 | |
David Barr | 8dc6a37 | 2010-12-02 21:40:20 +1100 | [diff] [blame] | 2297 | test_expect_success 'R: feature ls supported' ' |
| 2298 | echo "feature ls" | |
| 2299 | git fast-import |
| 2300 | ' |
| 2301 | |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2302 | test_expect_success 'R: feature cat-blob supported' ' |
| 2303 | echo "feature cat-blob" | |
| 2304 | git fast-import |
| 2305 | ' |
| 2306 | |
| 2307 | test_expect_success 'R: cat-blob-fd must be a nonnegative integer' ' |
| 2308 | test_must_fail git fast-import --cat-blob-fd=-1 </dev/null |
| 2309 | ' |
| 2310 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 2311 | test_expect_success !MINGW 'R: print old blob' ' |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2312 | blob=$(echo "yes it can" | git hash-object -w --stdin) && |
| 2313 | cat >expect <<-EOF && |
| 2314 | ${blob} blob 11 |
| 2315 | yes it can |
| 2316 | |
| 2317 | EOF |
| 2318 | echo "cat-blob $blob" | |
| 2319 | git fast-import --cat-blob-fd=6 6>actual && |
| 2320 | test_cmp expect actual |
| 2321 | ' |
| 2322 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 2323 | test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' ' |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2324 | echo hello >greeting && |
| 2325 | blob=$(git hash-object -w greeting) && |
| 2326 | cat >expect <<-EOF && |
| 2327 | ${blob} blob 6 |
| 2328 | hello |
| 2329 | |
| 2330 | EOF |
| 2331 | git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF && |
| 2332 | cat-blob $blob |
| 2333 | EOF |
| 2334 | test_cmp expect actual.3 && |
Johannes Sixt | acf3af2 | 2015-11-19 20:09:45 +0100 | [diff] [blame] | 2335 | test_must_be_empty actual.1 && |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2336 | git fast-import 3>actual.3 >actual.1 <<-EOF && |
| 2337 | option cat-blob-fd=3 |
| 2338 | cat-blob $blob |
| 2339 | EOF |
Johannes Sixt | acf3af2 | 2015-11-19 20:09:45 +0100 | [diff] [blame] | 2340 | test_must_be_empty actual.3 && |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2341 | test_cmp expect actual.1 |
| 2342 | ' |
| 2343 | |
Michael Haggerty | 28c7b1f | 2015-07-01 17:05:58 +0200 | [diff] [blame] | 2344 | test_expect_success !MINGW 'R: print mark for new blob' ' |
| 2345 | echo "effluentish" | git hash-object --stdin >expect && |
| 2346 | git fast-import --cat-blob-fd=6 6>actual <<-\EOF && |
| 2347 | blob |
| 2348 | mark :1 |
| 2349 | data <<BLOB_END |
| 2350 | effluentish |
| 2351 | BLOB_END |
| 2352 | get-mark :1 |
| 2353 | EOF |
| 2354 | test_cmp expect actual |
| 2355 | ' |
| 2356 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 2357 | test_expect_success !MINGW 'R: print new blob' ' |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2358 | blob=$(echo "yep yep yep" | git hash-object --stdin) && |
| 2359 | cat >expect <<-EOF && |
| 2360 | ${blob} blob 12 |
| 2361 | yep yep yep |
| 2362 | |
| 2363 | EOF |
| 2364 | git fast-import --cat-blob-fd=6 6>actual <<-\EOF && |
| 2365 | blob |
| 2366 | mark :1 |
| 2367 | data <<BLOB_END |
| 2368 | yep yep yep |
| 2369 | BLOB_END |
| 2370 | cat-blob :1 |
| 2371 | EOF |
| 2372 | test_cmp expect actual |
| 2373 | ' |
| 2374 | |
Junio C Hamano | f57a871 | 2014-07-21 15:09:27 -0700 | [diff] [blame] | 2375 | test_expect_success !MINGW 'R: print new blob by sha1' ' |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2376 | blob=$(echo "a new blob named by sha1" | git hash-object --stdin) && |
| 2377 | cat >expect <<-EOF && |
| 2378 | ${blob} blob 25 |
| 2379 | a new blob named by sha1 |
| 2380 | |
| 2381 | EOF |
| 2382 | git fast-import --cat-blob-fd=6 6>actual <<-EOF && |
| 2383 | blob |
| 2384 | data <<BLOB_END |
| 2385 | a new blob named by sha1 |
| 2386 | BLOB_END |
| 2387 | cat-blob $blob |
| 2388 | EOF |
| 2389 | test_cmp expect actual |
| 2390 | ' |
| 2391 | |
| 2392 | test_expect_success 'setup: big file' ' |
| 2393 | ( |
| 2394 | echo "the quick brown fox jumps over the lazy dog" >big && |
| 2395 | for i in 1 2 3 |
| 2396 | do |
| 2397 | cat big big big big >bigger && |
| 2398 | cat bigger bigger bigger bigger >big || |
| 2399 | exit |
| 2400 | done |
| 2401 | ) |
| 2402 | ' |
| 2403 | |
| 2404 | test_expect_success 'R: print two blobs to stdout' ' |
| 2405 | blob1=$(git hash-object big) && |
| 2406 | blob1_len=$(wc -c <big) && |
| 2407 | blob2=$(echo hello | git hash-object --stdin) && |
| 2408 | { |
| 2409 | echo ${blob1} blob $blob1_len && |
| 2410 | cat big && |
| 2411 | cat <<-EOF |
| 2412 | |
| 2413 | ${blob2} blob 6 |
| 2414 | hello |
| 2415 | |
| 2416 | EOF |
| 2417 | } >expect && |
| 2418 | { |
| 2419 | cat <<-\END_PART1 && |
| 2420 | blob |
| 2421 | mark :1 |
| 2422 | data <<data_end |
| 2423 | END_PART1 |
| 2424 | cat big && |
| 2425 | cat <<-\EOF |
| 2426 | data_end |
| 2427 | blob |
| 2428 | mark :2 |
| 2429 | data <<data_end |
| 2430 | hello |
| 2431 | data_end |
| 2432 | cat-blob :1 |
| 2433 | cat-blob :2 |
| 2434 | EOF |
| 2435 | } | |
| 2436 | git fast-import >actual && |
| 2437 | test_cmp expect actual |
| 2438 | ' |
| 2439 | |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2440 | test_expect_success PIPE 'R: copy using cat-file' ' |
| 2441 | expect_id=$(git hash-object big) && |
| 2442 | expect_len=$(wc -c <big) && |
| 2443 | echo $expect_id blob $expect_len >expect.response && |
| 2444 | |
| 2445 | rm -f blobs && |
| 2446 | cat >frontend <<-\FRONTEND_END && |
| 2447 | #!/bin/sh |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2448 | FRONTEND_END |
| 2449 | |
| 2450 | mkfifo blobs && |
| 2451 | ( |
| 2452 | export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE && |
Jonathan Nieder | 4de0bbd | 2010-12-13 03:28:05 -0600 | [diff] [blame] | 2453 | cat <<-\EOF && |
| 2454 | feature cat-blob |
| 2455 | blob |
| 2456 | mark :1 |
| 2457 | data <<BLOB |
| 2458 | EOF |
| 2459 | cat big && |
| 2460 | cat <<-\EOF && |
| 2461 | BLOB |
| 2462 | cat-blob :1 |
| 2463 | EOF |
| 2464 | |
| 2465 | read blob_id type size <&3 && |
| 2466 | echo "$blob_id $type $size" >response && |
Jeff King | 4886081 | 2016-06-30 05:07:54 -0400 | [diff] [blame] | 2467 | test_copy_bytes $size >blob <&3 && |
Jonathan Nieder | 4de0bbd | 2010-12-13 03:28:05 -0600 | [diff] [blame] | 2468 | read newline <&3 && |
| 2469 | |
| 2470 | cat <<-EOF && |
| 2471 | commit refs/heads/copied |
| 2472 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2473 | data <<COMMIT |
| 2474 | copy big file as file3 |
| 2475 | COMMIT |
| 2476 | M 644 inline file3 |
| 2477 | data <<BLOB |
| 2478 | EOF |
| 2479 | cat blob && |
| 2480 | echo BLOB |
| 2481 | ) 3<blobs | |
| 2482 | git fast-import --cat-blob-fd=3 3>blobs && |
David Barr | 85c6239 | 2010-11-28 13:45:01 -0600 | [diff] [blame] | 2483 | git show copied:file3 >actual && |
| 2484 | test_cmp expect.response response && |
| 2485 | test_cmp big actual |
| 2486 | ' |
| 2487 | |
Jonathan Nieder | 777f80d | 2010-11-28 13:45:58 -0600 | [diff] [blame] | 2488 | test_expect_success PIPE 'R: print blob mid-commit' ' |
| 2489 | rm -f blobs && |
| 2490 | echo "A blob from _before_ the commit." >expect && |
| 2491 | mkfifo blobs && |
| 2492 | ( |
| 2493 | exec 3<blobs && |
| 2494 | cat <<-EOF && |
| 2495 | feature cat-blob |
| 2496 | blob |
| 2497 | mark :1 |
| 2498 | data <<BLOB |
| 2499 | A blob from _before_ the commit. |
| 2500 | BLOB |
| 2501 | commit refs/heads/temporary |
| 2502 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2503 | data <<COMMIT |
| 2504 | Empty commit |
| 2505 | COMMIT |
| 2506 | cat-blob :1 |
| 2507 | EOF |
| 2508 | |
| 2509 | read blob_id type size <&3 && |
Jeff King | 4886081 | 2016-06-30 05:07:54 -0400 | [diff] [blame] | 2510 | test_copy_bytes $size >actual <&3 && |
Jonathan Nieder | 777f80d | 2010-11-28 13:45:58 -0600 | [diff] [blame] | 2511 | read newline <&3 && |
| 2512 | |
| 2513 | echo |
| 2514 | ) | |
| 2515 | git fast-import --cat-blob-fd=3 3>blobs && |
| 2516 | test_cmp expect actual |
| 2517 | ' |
| 2518 | |
| 2519 | test_expect_success PIPE 'R: print staged blob within commit' ' |
| 2520 | rm -f blobs && |
| 2521 | echo "A blob from _within_ the commit." >expect && |
| 2522 | mkfifo blobs && |
| 2523 | ( |
| 2524 | exec 3<blobs && |
| 2525 | cat <<-EOF && |
| 2526 | feature cat-blob |
| 2527 | commit refs/heads/within |
| 2528 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2529 | data <<COMMIT |
| 2530 | Empty commit |
| 2531 | COMMIT |
| 2532 | M 644 inline within |
| 2533 | data <<BLOB |
| 2534 | A blob from _within_ the commit. |
| 2535 | BLOB |
| 2536 | EOF |
| 2537 | |
| 2538 | to_get=$( |
| 2539 | echo "A blob from _within_ the commit." | |
| 2540 | git hash-object --stdin |
| 2541 | ) && |
| 2542 | echo "cat-blob $to_get" && |
| 2543 | |
| 2544 | read blob_id type size <&3 && |
Jeff King | 4886081 | 2016-06-30 05:07:54 -0400 | [diff] [blame] | 2545 | test_copy_bytes $size >actual <&3 && |
Jonathan Nieder | 777f80d | 2010-11-28 13:45:58 -0600 | [diff] [blame] | 2546 | read newline <&3 && |
| 2547 | |
| 2548 | echo deleteall |
| 2549 | ) | |
| 2550 | git fast-import --cat-blob-fd=3 3>blobs && |
| 2551 | test_cmp expect actual |
| 2552 | ' |
| 2553 | |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2554 | test_expect_success 'R: quiet option results in no stats being output' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2555 | cat >input <<-EOF && |
| 2556 | option git quiet |
| 2557 | blob |
| 2558 | data 3 |
| 2559 | hi |
| 2560 | |
| 2561 | EOF |
| 2562 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2563 | cat input | git fast-import 2> output && |
Johannes Sixt | acf3af2 | 2015-11-19 20:09:45 +0100 | [diff] [blame] | 2564 | test_must_be_empty output |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2565 | ' |
| 2566 | |
Sverre Rabbelier | be56862 | 2011-07-16 15:03:32 +0200 | [diff] [blame] | 2567 | test_expect_success 'R: feature done means terminating "done" is mandatory' ' |
| 2568 | echo feature done | test_must_fail git fast-import && |
| 2569 | test_must_fail git fast-import --done </dev/null |
| 2570 | ' |
| 2571 | |
| 2572 | test_expect_success 'R: terminating "done" with trailing gibberish is ok' ' |
| 2573 | git fast-import <<-\EOF && |
| 2574 | feature done |
| 2575 | done |
| 2576 | trailing gibberish |
| 2577 | EOF |
| 2578 | git fast-import <<-\EOF |
| 2579 | done |
| 2580 | more trailing gibberish |
| 2581 | EOF |
| 2582 | ' |
| 2583 | |
| 2584 | test_expect_success 'R: terminating "done" within commit' ' |
| 2585 | cat >expect <<-\EOF && |
| 2586 | OBJID |
| 2587 | :000000 100644 OBJID OBJID A hello.c |
| 2588 | :000000 100644 OBJID OBJID A hello2.c |
| 2589 | EOF |
| 2590 | git fast-import <<-EOF && |
| 2591 | commit refs/heads/done-ends |
| 2592 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2593 | data <<EOT |
| 2594 | Commit terminated by "done" command |
| 2595 | EOT |
| 2596 | M 100644 inline hello.c |
| 2597 | data <<EOT |
| 2598 | Hello, world. |
| 2599 | EOT |
| 2600 | C hello.c hello2.c |
| 2601 | done |
| 2602 | EOF |
| 2603 | git rev-list done-ends | |
| 2604 | git diff-tree -r --stdin --root --always | |
| 2605 | sed -e "s/$_x40/OBJID/g" >actual && |
| 2606 | test_cmp expect actual |
| 2607 | ' |
| 2608 | |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2609 | test_expect_success 'R: die on unknown option' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2610 | cat >input <<-EOF && |
| 2611 | option git non-existing-option |
| 2612 | EOF |
| 2613 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2614 | test_must_fail git fast-import <input |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2615 | ' |
| 2616 | |
| 2617 | test_expect_success 'R: unknown commandline options are rejected' '\ |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2618 | test_must_fail git fast-import --non-existing-option < /dev/null |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2619 | ' |
| 2620 | |
Jonathan Nieder | a9ff277 | 2010-11-28 13:42:46 -0600 | [diff] [blame] | 2621 | test_expect_success 'R: die on invalid option argument' ' |
| 2622 | echo "option git active-branches=-5" | |
| 2623 | test_must_fail git fast-import && |
| 2624 | echo "option git depth=" | |
| 2625 | test_must_fail git fast-import && |
| 2626 | test_must_fail git fast-import --depth="5 elephants" </dev/null |
| 2627 | ' |
| 2628 | |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2629 | test_expect_success 'R: ignore non-git options' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2630 | cat >input <<-EOF && |
| 2631 | option non-existing-vcs non-existing-option |
| 2632 | EOF |
| 2633 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2634 | git fast-import <input |
Sverre Rabbelier | 2792f26 | 2009-12-04 18:06:58 +0100 | [diff] [blame] | 2635 | ' |
| 2636 | |
Felipe Contreras | f4beed6 | 2016-05-17 16:40:23 -0500 | [diff] [blame] | 2637 | test_expect_success 'R: corrupt lines do not mess marks file' ' |
| 2638 | rm -f io.marks && |
| 2639 | blob=$(echo hi | git hash-object --stdin) && |
| 2640 | cat >expect <<-EOF && |
| 2641 | :3 0000000000000000000000000000000000000000 |
| 2642 | :1 $blob |
| 2643 | :2 $blob |
| 2644 | EOF |
| 2645 | cp expect io.marks && |
| 2646 | test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && |
| 2647 | |
| 2648 | EOF |
| 2649 | test_cmp expect io.marks |
| 2650 | ' |
| 2651 | |
Shawn O. Pearce | 5eef828 | 2010-02-01 09:27:35 -0800 | [diff] [blame] | 2652 | ## |
| 2653 | ## R: very large blobs |
| 2654 | ## |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2655 | test_expect_success 'R: blob bigger than threshold' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2656 | blobsize=$((2*1024*1024 + 53)) && |
| 2657 | test-genrandom bar $blobsize >expect && |
| 2658 | cat >input <<-INPUT_END && |
| 2659 | commit refs/heads/big-file |
| 2660 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2661 | data <<COMMIT |
| 2662 | R - big file |
| 2663 | COMMIT |
| 2664 | |
| 2665 | M 644 inline big1 |
| 2666 | data $blobsize |
| 2667 | INPUT_END |
| 2668 | cat expect >>input && |
| 2669 | cat >>input <<-INPUT_END && |
| 2670 | M 644 inline big2 |
| 2671 | data $blobsize |
| 2672 | INPUT_END |
| 2673 | cat expect >>input && |
| 2674 | echo >>input && |
| 2675 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2676 | test_create_repo R && |
Eric Wong | d9545c7 | 2016-04-25 21:17:28 +0000 | [diff] [blame] | 2677 | git --git-dir=R/.git config fastimport.unpackLimit 0 && |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2678 | git --git-dir=R/.git fast-import --big-file-threshold=1 <input |
| 2679 | ' |
Johannes Sixt | 05880b0 | 2012-04-20 08:25:09 +0200 | [diff] [blame] | 2680 | |
| 2681 | test_expect_success 'R: verify created pack' ' |
| 2682 | ( |
| 2683 | cd R && |
| 2684 | verify_packs -v > ../verify |
| 2685 | ) |
| 2686 | ' |
| 2687 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 2688 | test_expect_success 'R: verify written objects' ' |
| 2689 | git --git-dir=R/.git cat-file blob big-file:big1 >actual && |
| 2690 | test_cmp_bin expect actual && |
| 2691 | a=$(git --git-dir=R/.git rev-parse big-file:big1) && |
| 2692 | b=$(git --git-dir=R/.git rev-parse big-file:big2) && |
| 2693 | test $a = $b |
| 2694 | ' |
| 2695 | |
| 2696 | test_expect_success 'R: blob appears only once' ' |
| 2697 | n=$(grep $a verify | wc -l) && |
| 2698 | test 1 = $n |
| 2699 | ' |
Shawn O. Pearce | 5eef828 | 2010-02-01 09:27:35 -0800 | [diff] [blame] | 2700 | |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2701 | ### |
| 2702 | ### series S |
| 2703 | ### |
| 2704 | # |
| 2705 | # Make sure missing spaces and EOLs after mark references |
| 2706 | # cause errors. |
| 2707 | # |
| 2708 | # Setup: |
| 2709 | # |
| 2710 | # 1--2--4 |
| 2711 | # \ / |
| 2712 | # -3- |
| 2713 | # |
| 2714 | # commit marks: 301, 302, 303, 304 |
| 2715 | # blob marks: 403, 404, resp. |
| 2716 | # note mark: 202 |
| 2717 | # |
| 2718 | # The error message when a space is missing not at the |
| 2719 | # end of the line is: |
| 2720 | # |
| 2721 | # Missing space after .. |
| 2722 | # |
| 2723 | # or when extra characters come after the mark at the end |
| 2724 | # of the line: |
| 2725 | # |
| 2726 | # Garbage after .. |
| 2727 | # |
| 2728 | # or when the dataref is neither "inline " or a known SHA1, |
| 2729 | # |
| 2730 | # Invalid dataref .. |
| 2731 | # |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2732 | test_expect_success 'S: initialize for S tests' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 2733 | test_tick && |
| 2734 | |
| 2735 | cat >input <<-INPUT_END && |
| 2736 | commit refs/heads/S |
| 2737 | mark :301 |
| 2738 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2739 | data <<COMMIT |
| 2740 | commit 1 |
| 2741 | COMMIT |
| 2742 | M 100644 inline hello.c |
| 2743 | data <<BLOB |
| 2744 | blob 1 |
| 2745 | BLOB |
| 2746 | |
| 2747 | commit refs/heads/S |
| 2748 | mark :302 |
| 2749 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2750 | data <<COMMIT |
| 2751 | commit 2 |
| 2752 | COMMIT |
| 2753 | from :301 |
| 2754 | M 100644 inline hello.c |
| 2755 | data <<BLOB |
| 2756 | blob 2 |
| 2757 | BLOB |
| 2758 | |
| 2759 | blob |
| 2760 | mark :403 |
| 2761 | data <<BLOB |
| 2762 | blob 3 |
| 2763 | BLOB |
| 2764 | |
| 2765 | blob |
| 2766 | mark :202 |
| 2767 | data <<BLOB |
| 2768 | note 2 |
| 2769 | BLOB |
| 2770 | INPUT_END |
| 2771 | |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2772 | git fast-import --export-marks=marks <input |
| 2773 | ' |
| 2774 | |
| 2775 | # |
| 2776 | # filemodify, three datarefs |
| 2777 | # |
| 2778 | test_expect_success 'S: filemodify with garbage after mark must fail' ' |
| 2779 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2780 | commit refs/heads/S |
| 2781 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2782 | data <<COMMIT |
| 2783 | commit N |
| 2784 | COMMIT |
| 2785 | M 100644 :403x hello.c |
| 2786 | EOF |
| 2787 | cat err && |
| 2788 | test_i18ngrep "space after mark" err |
| 2789 | ' |
| 2790 | |
| 2791 | # inline is misspelled; fast-import thinks it is some unknown dataref |
| 2792 | test_expect_success 'S: filemodify with garbage after inline must fail' ' |
| 2793 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2794 | commit refs/heads/S |
| 2795 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2796 | data <<COMMIT |
| 2797 | commit N |
| 2798 | COMMIT |
| 2799 | M 100644 inlineX hello.c |
| 2800 | data <<BLOB |
| 2801 | inline |
| 2802 | BLOB |
| 2803 | EOF |
| 2804 | cat err && |
| 2805 | test_i18ngrep "nvalid dataref" err |
| 2806 | ' |
| 2807 | |
| 2808 | test_expect_success 'S: filemodify with garbage after sha1 must fail' ' |
| 2809 | sha1=$(grep :403 marks | cut -d\ -f2) && |
| 2810 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2811 | commit refs/heads/S |
| 2812 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2813 | data <<COMMIT |
| 2814 | commit N |
| 2815 | COMMIT |
| 2816 | M 100644 ${sha1}x hello.c |
| 2817 | EOF |
| 2818 | cat err && |
| 2819 | test_i18ngrep "space after SHA1" err |
| 2820 | ' |
| 2821 | |
| 2822 | # |
| 2823 | # notemodify, three ways to say dataref |
| 2824 | # |
Ville Skyttä | 6412757 | 2017-06-25 13:20:41 +0300 | [diff] [blame] | 2825 | test_expect_success 'S: notemodify with garbage after mark dataref must fail' ' |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2826 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2827 | commit refs/heads/S |
| 2828 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2829 | data <<COMMIT |
| 2830 | commit S note dataref markref |
| 2831 | COMMIT |
| 2832 | N :202x :302 |
| 2833 | EOF |
| 2834 | cat err && |
| 2835 | test_i18ngrep "space after mark" err |
| 2836 | ' |
| 2837 | |
| 2838 | test_expect_success 'S: notemodify with garbage after inline dataref must fail' ' |
| 2839 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2840 | commit refs/heads/S |
| 2841 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2842 | data <<COMMIT |
| 2843 | commit S note dataref inline |
| 2844 | COMMIT |
| 2845 | N inlineX :302 |
| 2846 | data <<BLOB |
| 2847 | note blob |
| 2848 | BLOB |
| 2849 | EOF |
| 2850 | cat err && |
| 2851 | test_i18ngrep "nvalid dataref" err |
| 2852 | ' |
| 2853 | |
| 2854 | test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' ' |
| 2855 | sha1=$(grep :202 marks | cut -d\ -f2) && |
| 2856 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2857 | commit refs/heads/S |
| 2858 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2859 | data <<COMMIT |
| 2860 | commit S note dataref sha1 |
| 2861 | COMMIT |
| 2862 | N ${sha1}x :302 |
| 2863 | EOF |
| 2864 | cat err && |
| 2865 | test_i18ngrep "space after SHA1" err |
| 2866 | ' |
| 2867 | |
| 2868 | # |
Richard Hansen | a8a5406 | 2013-09-04 15:04:31 -0400 | [diff] [blame] | 2869 | # notemodify, mark in commit-ish |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2870 | # |
Stefan Beller | 634c42d | 2014-09-21 17:02:57 +0200 | [diff] [blame] | 2871 | test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' ' |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2872 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2873 | commit refs/heads/Snotes |
| 2874 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2875 | data <<COMMIT |
Richard Hansen | a8a5406 | 2013-09-04 15:04:31 -0400 | [diff] [blame] | 2876 | commit S note commit-ish |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2877 | COMMIT |
| 2878 | N :202 :302x |
| 2879 | EOF |
| 2880 | cat err && |
| 2881 | test_i18ngrep "after mark" err |
| 2882 | ' |
| 2883 | |
| 2884 | # |
| 2885 | # from |
| 2886 | # |
| 2887 | test_expect_success 'S: from with garbage after mark must fail' ' |
Jeff King | 0a5e3c5 | 2015-03-20 06:09:22 -0400 | [diff] [blame] | 2888 | test_must_fail \ |
| 2889 | git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err && |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2890 | commit refs/heads/S2 |
| 2891 | mark :303 |
| 2892 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2893 | data <<COMMIT |
| 2894 | commit 3 |
| 2895 | COMMIT |
| 2896 | from :301x |
| 2897 | M 100644 :403 hello.c |
| 2898 | EOF |
| 2899 | |
Pete Wyckoff | 06454cb | 2012-04-07 18:59:20 -0400 | [diff] [blame] | 2900 | |
| 2901 | # go create the commit, need it for merge test |
| 2902 | git fast-import --import-marks=marks --export-marks=marks <<-EOF && |
| 2903 | commit refs/heads/S2 |
| 2904 | mark :303 |
| 2905 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2906 | data <<COMMIT |
| 2907 | commit 3 |
| 2908 | COMMIT |
| 2909 | from :301 |
| 2910 | M 100644 :403 hello.c |
| 2911 | EOF |
| 2912 | |
| 2913 | # now evaluate the error |
| 2914 | cat err && |
| 2915 | test_i18ngrep "after mark" err |
| 2916 | ' |
| 2917 | |
| 2918 | |
| 2919 | # |
| 2920 | # merge |
| 2921 | # |
| 2922 | test_expect_success 'S: merge with garbage after mark must fail' ' |
| 2923 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2924 | commit refs/heads/S |
| 2925 | mark :304 |
| 2926 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2927 | data <<COMMIT |
| 2928 | merge 4 |
| 2929 | COMMIT |
| 2930 | from :302 |
| 2931 | merge :303x |
| 2932 | M 100644 :403 hello.c |
| 2933 | EOF |
| 2934 | cat err && |
| 2935 | test_i18ngrep "after mark" err |
| 2936 | ' |
| 2937 | |
| 2938 | # |
| 2939 | # tag, from markref |
| 2940 | # |
| 2941 | test_expect_success 'S: tag with garbage after mark must fail' ' |
| 2942 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2943 | tag refs/tags/Stag |
| 2944 | from :302x |
| 2945 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 2946 | data <<TAG |
| 2947 | tag S |
| 2948 | TAG |
| 2949 | EOF |
| 2950 | cat err && |
| 2951 | test_i18ngrep "after mark" err |
| 2952 | ' |
| 2953 | |
| 2954 | # |
| 2955 | # cat-blob markref |
| 2956 | # |
| 2957 | test_expect_success 'S: cat-blob with garbage after mark must fail' ' |
| 2958 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2959 | cat-blob :403x |
| 2960 | EOF |
| 2961 | cat err && |
| 2962 | test_i18ngrep "after mark" err |
| 2963 | ' |
| 2964 | |
| 2965 | # |
| 2966 | # ls markref |
| 2967 | # |
| 2968 | test_expect_success 'S: ls with garbage after mark must fail' ' |
| 2969 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2970 | ls :302x hello.c |
| 2971 | EOF |
| 2972 | cat err && |
| 2973 | test_i18ngrep "space after mark" err |
| 2974 | ' |
| 2975 | |
| 2976 | test_expect_success 'S: ls with garbage after sha1 must fail' ' |
| 2977 | sha1=$(grep :302 marks | cut -d\ -f2) && |
| 2978 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
| 2979 | ls ${sha1}x hello.c |
| 2980 | EOF |
| 2981 | cat err && |
| 2982 | test_i18ngrep "space after tree-ish" err |
| 2983 | ' |
| 2984 | |
John Keeping | aca7061 | 2013-06-23 15:58:19 +0100 | [diff] [blame] | 2985 | ### |
| 2986 | ### series T (ls) |
| 2987 | ### |
| 2988 | # Setup is carried over from series S. |
| 2989 | |
John Keeping | e0eb6b9 | 2013-06-23 15:58:21 +0100 | [diff] [blame] | 2990 | test_expect_success 'T: ls root tree' ' |
John Keeping | aca7061 | 2013-06-23 15:58:19 +0100 | [diff] [blame] | 2991 | sed -e "s/Z\$//" >expect <<-EOF && |
| 2992 | 040000 tree $(git rev-parse S^{tree}) Z |
| 2993 | EOF |
| 2994 | sha1=$(git rev-parse --verify S) && |
| 2995 | git fast-import --import-marks=marks <<-EOF >actual && |
| 2996 | ls $sha1 "" |
| 2997 | EOF |
| 2998 | test_cmp expect actual |
| 2999 | ' |
| 3000 | |
Felipe Contreras | 4ee1b22 | 2014-04-20 13:59:27 -0500 | [diff] [blame] | 3001 | test_expect_success 'T: delete branch' ' |
| 3002 | git branch to-delete && |
| 3003 | git fast-import <<-EOF && |
| 3004 | reset refs/heads/to-delete |
| 3005 | from 0000000000000000000000000000000000000000 |
| 3006 | EOF |
| 3007 | test_must_fail git rev-parse --verify refs/heads/to-delete |
| 3008 | ' |
| 3009 | |
| 3010 | test_expect_success 'T: empty reset doesnt delete branch' ' |
| 3011 | git branch not-to-delete && |
| 3012 | git fast-import <<-EOF && |
| 3013 | reset refs/heads/not-to-delete |
| 3014 | EOF |
| 3015 | git show-ref && |
| 3016 | git rev-parse --verify refs/heads/not-to-delete |
| 3017 | ' |
| 3018 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3019 | ### |
| 3020 | ### series U (filedelete) |
| 3021 | ### |
| 3022 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3023 | test_expect_success 'U: initialize for U tests' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3024 | cat >input <<-INPUT_END && |
| 3025 | commit refs/heads/U |
| 3026 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3027 | data <<COMMIT |
| 3028 | test setup |
| 3029 | COMMIT |
| 3030 | M 100644 inline hello.c |
| 3031 | data <<BLOB |
| 3032 | blob 1 |
| 3033 | BLOB |
| 3034 | M 100644 inline good/night.txt |
| 3035 | data <<BLOB |
| 3036 | sleep well |
| 3037 | BLOB |
| 3038 | M 100644 inline good/bye.txt |
| 3039 | data <<BLOB |
| 3040 | au revoir |
| 3041 | BLOB |
| 3042 | |
| 3043 | INPUT_END |
| 3044 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3045 | git fast-import <input |
| 3046 | ' |
| 3047 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3048 | test_expect_success 'U: filedelete file succeeds' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3049 | cat >input <<-INPUT_END && |
| 3050 | commit refs/heads/U |
| 3051 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3052 | data <<COMMIT |
| 3053 | delete good/night.txt |
| 3054 | COMMIT |
| 3055 | from refs/heads/U^0 |
| 3056 | D good/night.txt |
| 3057 | |
| 3058 | INPUT_END |
| 3059 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3060 | git fast-import <input |
| 3061 | ' |
| 3062 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3063 | test_expect_success 'U: validate file delete result' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3064 | cat >expect <<-EOF && |
| 3065 | :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt |
| 3066 | EOF |
| 3067 | |
| 3068 | git diff-tree -M -r U^1 U >actual && |
| 3069 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3070 | compare_diff_raw expect actual |
| 3071 | ' |
| 3072 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3073 | test_expect_success 'U: filedelete directory succeeds' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3074 | cat >input <<-INPUT_END && |
| 3075 | commit refs/heads/U |
| 3076 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3077 | data <<COMMIT |
| 3078 | delete good dir |
| 3079 | COMMIT |
| 3080 | from refs/heads/U^0 |
| 3081 | D good |
| 3082 | |
| 3083 | INPUT_END |
| 3084 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3085 | git fast-import <input |
| 3086 | ' |
| 3087 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3088 | test_expect_success 'U: validate directory delete result' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3089 | cat >expect <<-EOF && |
| 3090 | :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt |
| 3091 | EOF |
| 3092 | |
| 3093 | git diff-tree -M -r U^1 U >actual && |
| 3094 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3095 | compare_diff_raw expect actual |
| 3096 | ' |
| 3097 | |
Maxim Bublis | 2668d69 | 2014-08-29 15:53:37 +0400 | [diff] [blame] | 3098 | test_expect_success 'U: filedelete root succeeds' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3099 | cat >input <<-INPUT_END && |
| 3100 | commit refs/heads/U |
| 3101 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3102 | data <<COMMIT |
| 3103 | must succeed |
| 3104 | COMMIT |
| 3105 | from refs/heads/U^0 |
| 3106 | D "" |
| 3107 | |
| 3108 | INPUT_END |
| 3109 | |
Johannes Sixt | d67824f | 2015-11-19 20:09:43 +0100 | [diff] [blame] | 3110 | git fast-import <input |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3111 | ' |
| 3112 | |
Maxim Bublis | 2668d69 | 2014-08-29 15:53:37 +0400 | [diff] [blame] | 3113 | test_expect_success 'U: validate root delete result' ' |
Johannes Sixt | 68297e0 | 2015-11-19 20:09:49 +0100 | [diff] [blame] | 3114 | cat >expect <<-EOF && |
| 3115 | :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c |
| 3116 | EOF |
| 3117 | |
| 3118 | git diff-tree -M -r U^1 U >actual && |
| 3119 | |
Maxim Bublis | 8d30d8a | 2014-08-29 15:53:36 +0400 | [diff] [blame] | 3120 | compare_diff_raw expect actual |
| 3121 | ' |
| 3122 | |
Eric Rannaud | 30e215a | 2017-09-28 20:09:36 -0700 | [diff] [blame] | 3123 | ### |
| 3124 | ### series V (checkpoint) |
| 3125 | ### |
| 3126 | |
| 3127 | # The commands in input_file should not produce any output on the file |
| 3128 | # descriptor set with --cat-blob-fd (or stdout if unspecified). |
| 3129 | # |
| 3130 | # To make sure you're observing the side effects of checkpoint *before* |
| 3131 | # fast-import terminates (and thus writes out its state), check that the |
| 3132 | # fast-import process is still running using background_import_still_running |
| 3133 | # *after* evaluating the test conditions. |
| 3134 | background_import_then_checkpoint () { |
| 3135 | options=$1 |
| 3136 | input_file=$2 |
| 3137 | |
| 3138 | mkfifo V.input |
| 3139 | exec 8<>V.input |
| 3140 | rm V.input |
| 3141 | |
| 3142 | mkfifo V.output |
| 3143 | exec 9<>V.output |
| 3144 | rm V.output |
| 3145 | |
| 3146 | git fast-import $options <&8 >&9 & |
| 3147 | echo $! >V.pid |
| 3148 | # We don't mind if fast-import has already died by the time the test |
| 3149 | # ends. |
| 3150 | test_when_finished "exec 8>&-; exec 9>&-; kill $(cat V.pid) || true" |
| 3151 | |
| 3152 | # Start in the background to ensure we adhere strictly to (blocking) |
| 3153 | # pipes writing sequence. We want to assume that the write below could |
| 3154 | # block, e.g. if fast-import blocks writing its own output to &9 |
| 3155 | # because there is no reader on &9 yet. |
| 3156 | ( |
| 3157 | cat "$input_file" |
| 3158 | echo "checkpoint" |
| 3159 | echo "progress checkpoint" |
| 3160 | ) >&8 & |
| 3161 | |
| 3162 | error=1 ;# assume the worst |
| 3163 | while read output <&9 |
| 3164 | do |
| 3165 | if test "$output" = "progress checkpoint" |
| 3166 | then |
| 3167 | error=0 |
| 3168 | break |
| 3169 | fi |
| 3170 | # otherwise ignore cruft |
| 3171 | echo >&2 "cruft: $output" |
| 3172 | done |
| 3173 | |
| 3174 | if test $error -eq 1 |
| 3175 | then |
| 3176 | false |
| 3177 | fi |
| 3178 | } |
| 3179 | |
| 3180 | background_import_still_running () { |
| 3181 | if ! kill -0 "$(cat V.pid)" |
| 3182 | then |
| 3183 | echo >&2 "background fast-import terminated too early" |
| 3184 | false |
| 3185 | fi |
| 3186 | } |
| 3187 | |
| 3188 | test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' ' |
| 3189 | cat >input <<-INPUT_END && |
| 3190 | progress foo |
| 3191 | progress bar |
| 3192 | |
| 3193 | INPUT_END |
| 3194 | |
| 3195 | background_import_then_checkpoint "" input && |
| 3196 | background_import_still_running |
| 3197 | ' |
| 3198 | |
| 3199 | test_expect_success PIPE 'V: checkpoint updates refs after reset' ' |
| 3200 | cat >input <<-\INPUT_END && |
| 3201 | reset refs/heads/V |
| 3202 | from refs/heads/U |
| 3203 | |
| 3204 | INPUT_END |
| 3205 | |
| 3206 | background_import_then_checkpoint "" input && |
| 3207 | test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" && |
| 3208 | background_import_still_running |
| 3209 | ' |
| 3210 | |
| 3211 | test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' ' |
| 3212 | cat >input <<-INPUT_END && |
| 3213 | commit refs/heads/V |
| 3214 | mark :1 |
| 3215 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3216 | data 0 |
| 3217 | from refs/heads/U |
| 3218 | |
| 3219 | INPUT_END |
| 3220 | |
| 3221 | background_import_then_checkpoint "--export-marks=marks.actual" input && |
| 3222 | |
| 3223 | echo ":1 $(git rev-parse --verify V)" >marks.expected && |
| 3224 | |
| 3225 | test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" && |
| 3226 | test_cmp marks.expected marks.actual && |
| 3227 | background_import_still_running |
| 3228 | ' |
| 3229 | |
| 3230 | # Re-create the exact same commit, but on a different branch: no new object is |
| 3231 | # created in the database, but the refs and marks still need to be updated. |
| 3232 | test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' ' |
| 3233 | cat >input <<-INPUT_END && |
| 3234 | commit refs/heads/V2 |
| 3235 | mark :2 |
| 3236 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3237 | data 0 |
| 3238 | from refs/heads/U |
| 3239 | |
| 3240 | INPUT_END |
| 3241 | |
| 3242 | background_import_then_checkpoint "--export-marks=marks.actual" input && |
| 3243 | |
| 3244 | echo ":2 $(git rev-parse --verify V2)" >marks.expected && |
| 3245 | |
| 3246 | test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" && |
| 3247 | test_cmp marks.expected marks.actual && |
| 3248 | background_import_still_running |
| 3249 | ' |
| 3250 | |
| 3251 | test_expect_success PIPE 'V: checkpoint updates tags after tag' ' |
| 3252 | cat >input <<-INPUT_END && |
| 3253 | tag Vtag |
| 3254 | from refs/heads/V |
| 3255 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
| 3256 | data 0 |
| 3257 | |
| 3258 | INPUT_END |
| 3259 | |
| 3260 | background_import_then_checkpoint "" input && |
| 3261 | git show-ref -d Vtag && |
| 3262 | background_import_still_running |
| 3263 | ' |
| 3264 | |
Shawn O. Pearce | 50aee99 | 2007-01-18 13:26:24 -0500 | [diff] [blame] | 3265 | test_done |