| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test exotic situations with marks' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup dump of basic history' ' |
| 8 | test_commit one && |
| 9 | git fast-export --export-marks=marks HEAD >dump |
| 10 | ' |
| 11 | |
| 12 | test_expect_success 'setup large marks file' ' |
| 13 | # normally a marks file would have a lot of useful, unique |
| 14 | # marks. But for our purposes, just having a lot of nonsense |
| 15 | # ones is fine. Start at 1024 to avoid clashing with marks |
| 16 | # legitimately used in our tiny dump. |
| 17 | blob=$(git rev-parse HEAD:one.t) && |
| 18 | for i in $(test_seq 1024 16384) |
| 19 | do |
| 20 | echo ":$i $blob" || return 1 |
| 21 | done >>marks |
| 22 | ' |
| 23 | |
| 24 | test_expect_success 'import with large marks file' ' |
| 25 | git fast-import --import-marks=marks <dump |
| 26 | ' |
| 27 | |
| 28 | test_expect_success 'setup dump with submodule' ' |
| 29 | test_config_global protocol.file.allow always && |
| 30 | git submodule add "$PWD" sub && |
| 31 | git commit -m "add submodule" && |
| 32 | git fast-export HEAD >dump |
| 33 | ' |
| 34 | |
| 35 | test_expect_success 'setup submodule mapping with large id' ' |
| 36 | old=$(git rev-parse HEAD:sub) && |
| 37 | new=$(echo $old | sed s/./a/g) && |
| 38 | echo ":12345 $old" >from && |
| 39 | echo ":12345 $new" >to |
| 40 | ' |
| 41 | |
| 42 | test_expect_success 'import with submodule mapping' ' |
| 43 | git init dst && |
| 44 | git -C dst fast-import \ |
| 45 | --rewrite-submodules-from=sub:../from \ |
| 46 | --rewrite-submodules-to=sub:../to \ |
| 47 | <dump && |
| 48 | git -C dst rev-parse HEAD:sub >actual && |
| 49 | echo "$new" >expect && |
| 50 | test_cmp expect actual |
| 51 | ' |
| 52 | |
| 53 | test_expect_success 'paths adjusted for relative subdir' ' |
| 54 | git init deep-dst && |
| 55 | mkdir deep-dst/subdir && |
| 56 | >deep-dst/subdir/empty-marks && |
| 57 | git -C deep-dst/subdir fast-import \ |
| 58 | --rewrite-submodules-from=sub:../../from \ |
| 59 | --rewrite-submodules-to=sub:../../to \ |
| 60 | --import-marks=empty-marks \ |
| 61 | --export-marks=exported-marks \ |
| 62 | --export-pack-edges=exported-edges \ |
| 63 | <dump && |
| 64 | # we do not bother checking resulting repo; we just care that nothing |
| 65 | # complained about failing to open files for reading, and that files |
| 66 | # for writing were created in the expected spot |
| 67 | test_path_is_file deep-dst/subdir/exported-marks && |
| 68 | test_path_is_file deep-dst/subdir/exported-edges |
| 69 | ' |
| 70 | |
| 71 | test_expect_success 'relative marks are not affected by subdir' ' |
| 72 | git init deep-relative && |
| 73 | mkdir deep-relative/subdir && |
| 74 | git -C deep-relative/subdir fast-import \ |
| 75 | --relative-marks \ |
| 76 | --export-marks=exported-marks \ |
| 77 | <dump && |
| 78 | test_path_is_missing deep-relative/subdir/exported-marks && |
| 79 | test_path_is_file deep-relative/.git/info/fast-import/exported-marks |
| 80 | ' |
| 81 | |
| 82 | test_done |