summaryrefslogtreecommitdiff
path: root/t/t5526-fetch-submodules.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-01-29 20:47:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-29 20:47:54 (GMT)
commit5d3635db19c6dff4fb063fabfa4161fd3b8285f0 (patch)
tree30671c79e96d06267eda7d088a4ef7fd86c3ad47 /t/t5526-fetch-submodules.sh
parentf33989464ecfc05a937328430b7e74819f7285dd (diff)
parentbe76c2128234d94b47f7087152ee55d08bb65d88 (diff)
downloadgit-5d3635db19c6dff4fb063fabfa4161fd3b8285f0.zip
git-5d3635db19c6dff4fb063fabfa4161fd3b8285f0.tar.gz
git-5d3635db19c6dff4fb063fabfa4161fd3b8285f0.tar.bz2
Merge branch 'sb/submodule-recursive-fetch-gets-the-tip'
"git fetch --recurse-submodules" may not fetch the necessary commit that is bound to the superproject, which is getting corrected. * sb/submodule-recursive-fetch-gets-the-tip: fetch: ensure submodule objects fetched submodule.c: fetch in submodules git directory instead of in worktree submodule: migrate get_next_submodule to use repository structs repository: repo_submodule_init to take a submodule struct submodule: store OIDs in changed_submodule_names submodule.c: tighten scope of changed_submodule_names struct submodule.c: sort changed_submodule_names before searching it submodule.c: fix indentation sha1-array: provide oid_array_filter
Diffstat (limited to 't/t5526-fetch-submodules.sh')
-rwxr-xr-xt/t5526-fetch-submodules.sh117
1 files changed, 117 insertions, 0 deletions
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index a031755..63205df 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -602,4 +602,121 @@ test_expect_success "fetch new commits when submodule got renamed" '
test_cmp expect actual
'
+test_expect_success "fetch new submodule commits on-demand outside standard refspec" '
+ # add a second submodule and ensure it is around in downstream first
+ git clone submodule sub1 &&
+ git submodule add ./sub1 &&
+ git commit -m "adding a second submodule" &&
+ git -C downstream pull &&
+ git -C downstream submodule update --init --recursive &&
+
+ git checkout --detach &&
+
+ C=$(git -C submodule commit-tree -m "new change outside refs/heads" HEAD^{tree}) &&
+ git -C submodule update-ref refs/changes/1 $C &&
+ git update-index --cacheinfo 160000 $C submodule &&
+ test_tick &&
+
+ D=$(git -C sub1 commit-tree -m "new change outside refs/heads" HEAD^{tree}) &&
+ git -C sub1 update-ref refs/changes/2 $D &&
+ git update-index --cacheinfo 160000 $D sub1 &&
+
+ git commit -m "updated submodules outside of refs/heads" &&
+ E=$(git rev-parse HEAD) &&
+ git update-ref refs/changes/3 $E &&
+ (
+ cd downstream &&
+ git fetch --recurse-submodules origin refs/changes/3:refs/heads/my_branch &&
+ git -C submodule cat-file -t $C &&
+ git -C sub1 cat-file -t $D &&
+ git checkout --recurse-submodules FETCH_HEAD
+ )
+'
+
+test_expect_success 'fetch new submodule commit on-demand in FETCH_HEAD' '
+ # depends on the previous test for setup
+
+ C=$(git -C submodule commit-tree -m "another change outside refs/heads" HEAD^{tree}) &&
+ git -C submodule update-ref refs/changes/4 $C &&
+ git update-index --cacheinfo 160000 $C submodule &&
+ test_tick &&
+
+ D=$(git -C sub1 commit-tree -m "another change outside refs/heads" HEAD^{tree}) &&
+ git -C sub1 update-ref refs/changes/5 $D &&
+ git update-index --cacheinfo 160000 $D sub1 &&
+
+ git commit -m "updated submodules outside of refs/heads" &&
+ E=$(git rev-parse HEAD) &&
+ git update-ref refs/changes/6 $E &&
+ (
+ cd downstream &&
+ git fetch --recurse-submodules origin refs/changes/6 &&
+ git -C submodule cat-file -t $C &&
+ git -C sub1 cat-file -t $D &&
+ git checkout --recurse-submodules FETCH_HEAD
+ )
+'
+
+test_expect_success 'fetch new submodule commits on-demand without .gitmodules entry' '
+ # depends on the previous test for setup
+
+ git config -f .gitmodules --remove-section submodule.sub1 &&
+ git add .gitmodules &&
+ git commit -m "delete gitmodules file" &&
+ git checkout -B master &&
+ git -C downstream fetch &&
+ git -C downstream checkout origin/master &&
+
+ C=$(git -C submodule commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
+ git -C submodule update-ref refs/changes/7 $C &&
+ git update-index --cacheinfo 160000 $C submodule &&
+ test_tick &&
+
+ D=$(git -C sub1 commit-tree -m "yet another change outside refs/heads" HEAD^{tree}) &&
+ git -C sub1 update-ref refs/changes/8 $D &&
+ git update-index --cacheinfo 160000 $D sub1 &&
+
+ git commit -m "updated submodules outside of refs/heads" &&
+ E=$(git rev-parse HEAD) &&
+ git update-ref refs/changes/9 $E &&
+ (
+ cd downstream &&
+ git fetch --recurse-submodules origin refs/changes/9 &&
+ git -C submodule cat-file -t $C &&
+ git -C sub1 cat-file -t $D &&
+ git checkout --recurse-submodules FETCH_HEAD
+ )
+'
+
+test_expect_success 'fetch new submodule commit intermittently referenced by superproject' '
+ # depends on the previous test for setup
+
+ D=$(git -C sub1 commit-tree -m "change 10 outside refs/heads" HEAD^{tree}) &&
+ E=$(git -C sub1 commit-tree -m "change 11 outside refs/heads" HEAD^{tree}) &&
+ F=$(git -C sub1 commit-tree -m "change 12 outside refs/heads" HEAD^{tree}) &&
+
+ git -C sub1 update-ref refs/changes/10 $D &&
+ git update-index --cacheinfo 160000 $D sub1 &&
+ git commit -m "updated submodules outside of refs/heads" &&
+
+ git -C sub1 update-ref refs/changes/11 $E &&
+ git update-index --cacheinfo 160000 $E sub1 &&
+ git commit -m "updated submodules outside of refs/heads" &&
+
+ git -C sub1 update-ref refs/changes/12 $F &&
+ git update-index --cacheinfo 160000 $F sub1 &&
+ git commit -m "updated submodules outside of refs/heads" &&
+
+ G=$(git rev-parse HEAD) &&
+ git update-ref refs/changes/13 $G &&
+ (
+ cd downstream &&
+ git fetch --recurse-submodules origin refs/changes/13 &&
+
+ git -C sub1 cat-file -t $D &&
+ git -C sub1 cat-file -t $E &&
+ git -C sub1 cat-file -t $F
+ )
+'
+
test_done