Skip to contentSkip to conversation

git-common-dir: make submodule related variables worktree specific

PATCH In review Max Kirillov 1 participant 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-common-dir: make submodule related variables worktree specific

Then submodules in different worktrees will be fully independent. They can, and should, be initialised and updated separately.

Update t7410-submodule-checkout-to.sh to consider this.

---
Now when there is implementation for worktree-specific module it is possible to make submodules in different worktrees fully independent.

Should be applied over current next (111ea16e53) with merged $gmane/266520 and $gmane/266614

 t/t7410-submodule-checkout-to.sh | 38 ++++++++++++++++++++++++--------------
 templates/info--config.worktree  |  6 ++++++
 2 files changed, 30 insertions(+), 14 deletions(-)
t/t7410-submodule-checkout-to.sh +24 -14
index 4a9dae8..9534a23 100755
@@ -8,20 +8,22 @@ base_path=$(pwd -P)
 
 test_expect_success 'setup: make origin' \
     'mkdir -p origin/sub && ( cd origin/sub && git init &&
-	echo file1 >file1 &&
-	git add file1 &&
-	git commit -m file1 ) &&
+	test_commit sub_init file ) &&
+    mkdir -p origin/sub2 && ( cd origin/sub2 && git init &&
+	test_commit sub2_init file ) &&
     mkdir -p origin/main && ( cd origin/main && git init &&
 	git submodule add ../sub &&
-	git commit -m "add sub" ) &&
+	git submodule add ../sub2 &&
+	git commit -m "add submodules" ) &&
     ( cd origin/sub &&
-	echo file1updated >file1 &&
-	git add file1 &&
-	git commit -m "file1 updated" ) &&
+	test_commit sub_update file ) &&
+    ( cd origin/sub2 &&
+	test_commit sub2_update file ) &&
     ( cd origin/main/sub && git pull ) &&
+    ( cd origin/main/sub2 && git pull ) &&
     ( cd origin/main &&
-	git add sub &&
-	git commit -m "sub updated" )'
+	git add sub sub2 &&
+	git commit -m "submodules updated" )'
 
 test_expect_success 'setup: clone' \
     'mkdir clone && ( cd clone &&
@@ -35,17 +37,25 @@ test_expect_success 'checkout main' \
     (cd clone/main &&
 	git checkout --to "$base_path/default_checkout/main" "$rev1_hash_main")'
 
-test_expect_failure 'can see submodule diffs just after checkout' \
-    '(cd default_checkout/main && git diff --submodule master"^!" | grep "file1 updated")'
+test_expect_success 'cannot see submodule diffs just after checking out main' \
+    '(cd default_checkout/main &&
+	git diff --submodule master"^!" | grep "Submodule sub .*(not checked out)" &&
+	git diff --submodule master"^!" | grep "Submodule sub2 .*(not checked out)")'
 
 test_expect_success 'checkout main and initialize independed clones' \
     'mkdir fully_cloned_submodule &&
     (cd clone/main &&
 	git checkout --to "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") &&
-    (cd fully_cloned_submodule/main && git submodule update)'
+    (cd fully_cloned_submodule/main &&
+	git submodule init sub &&
+	git submodule update)'
 
 test_expect_success 'can see submodule diffs after independed cloning' \
-    '(cd fully_cloned_submodule/main && git diff --submodule master"^!" | grep "file1 updated")'
+    '(cd fully_cloned_submodule/main && git diff --submodule master"^!" | grep "sub_update")'
+
+test_expect_success 'sub2 remains uninitialized' '
+    (cd fully_cloned_submodule/main &&
+	git diff --submodule master"^!" | grep "Submodule sub2 .*(not checked out)")'
 
 test_expect_success 'checkout sub manually' \
     'mkdir linked_submodule &&
@@ -55,7 +65,7 @@ test_expect_success 'checkout sub manually' \
 	git checkout --to "$base_path/linked_submodule/main/sub" "$rev1_hash_sub")'
 
 test_expect_success 'can see submodule diffs after manual checkout of linked submodule' \
-    '(cd linked_submodule/main && git diff --submodule master"^!" | grep "file1 updated")'
+    '(cd linked_submodule/main && git diff --submodule master"^!" | grep "sub_update")'
 
 # test_expect_success 'archive' 'tar czf ../t7410.tar.gz .'
 
templates/info--config.worktree +6 -0
index f358230..c78916a 100644
@@ -1,2 +1,8 @@
 core.worktree
 core.bare
+submodule.*.path
+submodule.*.url
+submodule.*.update
+submodule.*.branch
+submodule.*.fetchRecurseSubmodules
+submodule.*.ignore
Signature · 1 line
2.3.4.2801.g3d0809b
#1 lore raw

PATCH v2 1/1 git-common-dir: make submodule related variables worktree specific

Then submodules in different worktrees will be fully independent. They can, and should, be initialised and updated separately.

Update t7410-submodule-checkout-to.sh to consider this.

---
Some local slipped into patch which can break applying. Now hopely correct

 t/t7410-submodule-checkout-to.sh | 38 ++++++++++++++++++++++++--------------
 templates/info--config.worktree  |  6 ++++++
 2 files changed, 30 insertions(+), 14 deletions(-)
t/t7410-submodule-checkout-to.sh +24 -14
index b43391a..ce41e6b 100755
@@ -8,20 +8,22 @@ base_path=$(pwd -P)
 
 test_expect_success 'setup: make origin' \
     'mkdir -p origin/sub && ( cd origin/sub && git init &&
-	echo file1 >file1 &&
-	git add file1 &&
-	git commit -m file1 ) &&
+	test_commit sub_init file ) &&
+    mkdir -p origin/sub2 && ( cd origin/sub2 && git init &&
+	test_commit sub2_init file ) &&
     mkdir -p origin/main && ( cd origin/main && git init &&
 	git submodule add ../sub &&
-	git commit -m "add sub" ) &&
+	git submodule add ../sub2 &&
+	git commit -m "add submodules" ) &&
     ( cd origin/sub &&
-	echo file1updated >file1 &&
-	git add file1 &&
-	git commit -m "file1 updated" ) &&
+	test_commit sub_update file ) &&
+    ( cd origin/sub2 &&
+	test_commit sub2_update file ) &&
     ( cd origin/main/sub && git pull ) &&
+    ( cd origin/main/sub2 && git pull ) &&
     ( cd origin/main &&
-	git add sub &&
-	git commit -m "sub updated" )'
+	git add sub sub2 &&
+	git commit -m "submodules updated" )'
 
 test_expect_success 'setup: clone' \
     'mkdir clone && ( cd clone &&
@@ -35,17 +37,25 @@ test_expect_success 'checkout main' \
     (cd clone/main &&
 	git checkout --to "$base_path/default_checkout/main" "$rev1_hash_main")'
 
-test_expect_failure 'can see submodule diffs just after checkout' \
-    '(cd default_checkout/main && git diff --submodule master"^!" | grep "file1 updated")'
+test_expect_success 'cannot see submodule diffs just after checking out main' \
+    '(cd default_checkout/main &&
+	git diff --submodule master"^!" | grep "Submodule sub .*(not checked out)" &&
+	git diff --submodule master"^!" | grep "Submodule sub2 .*(not checked out)")'
 
 test_expect_success 'checkout main and initialize independed clones' \
     'mkdir fully_cloned_submodule &&
     (cd clone/main &&
 	git checkout --to "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") &&
-    (cd fully_cloned_submodule/main && git submodule update)'
+    (cd fully_cloned_submodule/main &&
+	git submodule init sub &&
+	git submodule update)'
 
 test_expect_success 'can see submodule diffs after independed cloning' \
-    '(cd fully_cloned_submodule/main && git diff --submodule master"^!" | grep "file1 updated")'
+    '(cd fully_cloned_submodule/main && git diff --submodule master"^!" | grep "sub_update")'
+
+test_expect_success 'sub2 remains uninitialized' '
+    (cd fully_cloned_submodule/main &&
+	git diff --submodule master"^!" | grep "Submodule sub2 .*(not checked out)")'
 
 test_expect_success 'checkout sub manually' \
     'mkdir linked_submodule &&
@@ -55,6 +65,6 @@ test_expect_success 'checkout sub manually' \
 	git checkout --to "$base_path/linked_submodule/main/sub" "$rev1_hash_sub")'
 
 test_expect_success 'can see submodule diffs after manual checkout of linked submodule' \
-    '(cd linked_submodule/main && git diff --submodule master"^!" | grep "file1 updated")'
+    '(cd linked_submodule/main && git diff --submodule master"^!" | grep "sub_update")'
 
 test_done
templates/info--config.worktree +6 -0
index f358230..c78916a 100644
@@ -1,2 +1,8 @@
 core.worktree
 core.bare
+submodule.*.path
+submodule.*.url
+submodule.*.update
+submodule.*.branch
+submodule.*.fetchRecurseSubmodules
+submodule.*.ignore
Signature · 1 line
2.3.4.2801.g3d0809b
#2 lore raw
In reply to Max Kirillov
Quoted 11 lines · Max Kirillov

Then submodules in different worktrees will be fully independent. They can, and should, be initialised and updated separately.

Update t7410-submodule-checkout-to.sh to consider this.

---
Now when there is implementation for worktree-specific module it is possible to make submodules in different worktrees fully independent.

Should be applied over current next (111ea16e53) with merged $gmane/266520 and $gmane/266614

I mean $gmane/266520 and $gmane/265762