|
18 | 18 | fi
|
19 | 19 |
|
20 | 20 | test_expect_success 'setup' '
|
21 |
| - git config set --global protocol.file.allow always |
| 21 | + git config set --global protocol.file.allow always && |
| 22 | + # Some tests migrate the ref storage format, which does not work with |
| 23 | + # reflogs at the time of writing these tests. |
| 24 | + git config set --global core.logAllRefUpdates false |
| 25 | +' |
| 26 | + |
| 27 | +test_expect_success 'add existing repository with different ref storage format' ' |
| 28 | + test_when_finished "rm -rf parent" && |
| 29 | +
|
| 30 | + git init parent && |
| 31 | + ( |
| 32 | + cd parent && |
| 33 | + test_commit parent && |
| 34 | + git init --ref-format=$OTHER_FORMAT submodule && |
| 35 | + test_commit -C submodule submodule && |
| 36 | + git submodule add ./submodule |
| 37 | + ) |
22 | 38 | '
|
23 | 39 |
|
24 | 40 | test_expect_success 'recursive clone propagates ref storage format' '
|
@@ -59,6 +75,58 @@ test_expect_success 'clone submodules with different ref storage format' '
|
59 | 75 | test_ref_format downstream/submodule "$OTHER_FORMAT"
|
60 | 76 | '
|
61 | 77 |
|
| 78 | +test_expect_success 'status with mixed submodule ref storages' ' |
| 79 | + test_when_finished "rm -rf submodule main" && |
| 80 | +
|
| 81 | + git init submodule && |
| 82 | + test_commit -C submodule submodule-initial && |
| 83 | + git init main && |
| 84 | + git -C main submodule add "file://$(pwd)/submodule" && |
| 85 | + git -C main commit -m "add submodule" && |
| 86 | + git -C main/submodule refs migrate --ref-format=$OTHER_FORMAT && |
| 87 | +
|
| 88 | + # The main repository should use the default ref format now, whereas |
| 89 | + # the submodule should use the other format. |
| 90 | + test_ref_format main "$GIT_DEFAULT_REF_FORMAT" && |
| 91 | + test_ref_format main/submodule "$OTHER_FORMAT" && |
| 92 | +
|
| 93 | + cat >expect <<-EOF && |
| 94 | + $(git -C main/submodule rev-parse HEAD) submodule (submodule-initial) |
| 95 | + EOF |
| 96 | + git -C main submodule status >actual && |
| 97 | + test_cmp expect actual |
| 98 | +' |
| 99 | + |
| 100 | +test_expect_success 'recursive pull with mixed formats' ' |
| 101 | + test_when_finished "rm -rf submodule upstream downstream" && |
| 102 | +
|
| 103 | + # Set up the initial structure with an upstream repository that has a |
| 104 | + # submodule, as well as a downstream clone of the upstream repository. |
| 105 | + git init submodule && |
| 106 | + test_commit -C submodule submodule-initial && |
| 107 | + git init upstream && |
| 108 | + git -C upstream submodule add "file://$(pwd)/submodule" && |
| 109 | + git -C upstream commit -m "upstream submodule" && |
| 110 | +
|
| 111 | + # Clone the upstream repository such that the main repo and its |
| 112 | + # submodules have different formats. |
| 113 | + git clone --no-recurse-submodules "file://$(pwd)/upstream" downstream && |
| 114 | + git -C downstream submodule update --init --ref-format=$OTHER_FORMAT && |
| 115 | + test_ref_format downstream "$GIT_DEFAULT_REF_FORMAT" && |
| 116 | + test_ref_format downstream/submodule "$OTHER_FORMAT" && |
| 117 | +
|
| 118 | + # Update the upstream submodule as well as the owning repository such |
| 119 | + # that we can do a recursive pull. |
| 120 | + test_commit -C submodule submodule-update && |
| 121 | + git -C upstream/submodule pull && |
| 122 | + git -C upstream commit -am "update the submodule" && |
| 123 | +
|
| 124 | + git -C downstream pull --recurse-submodules && |
| 125 | + git -C upstream/submodule rev-parse HEAD >expect && |
| 126 | + git -C downstream/submodule rev-parse HEAD >actual && |
| 127 | + test_cmp expect actual |
| 128 | +' |
| 129 | + |
62 | 130 | done
|
63 | 131 |
|
64 | 132 | test_done
|
0 commit comments