Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Blain <levraiphilippeblain@gmail.com>2020-01-21 18:01:14 +0300
committerJunio C Hamano <gitster@pobox.com>2020-01-23 00:36:03 +0300
commit773c60a45e01f1e6631afe1cce9da3ed67d37a3a (patch)
tree6feedb9df1e244da316f95534632230ec0f1b90e /t/t2405-worktree-submodule.sh
parentd0654dc308b0ba76dd8ed7bbb33c8d8f7aacd783 (diff)
t7410: rename to t2405-worktree-submodule.sh
This test was added in df56607dff (git-common-dir: make "modules/" per-working-directory directory, 2014-11-30), back when the 'git worktree' command did not exist and 'git checkout --to' was used to create supplementary worktrees. Since this file contains tests for the interaction of 'git worktree' with submodules, rename it to t2405-worktree-submodule.sh, following the naming scheme for tests checking the behavior of various commands with submodules. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2405-worktree-submodule.sh')
-rwxr-xr-xt/t2405-worktree-submodule.sh77
1 files changed, 77 insertions, 0 deletions
diff --git a/t/t2405-worktree-submodule.sh b/t/t2405-worktree-submodule.sh
new file mode 100755
index 0000000000..f2eee328cc
--- /dev/null
+++ b/t/t2405-worktree-submodule.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+test_description='Combination of submodules and multiple worktrees'
+
+. ./test-lib.sh
+
+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
+ ) &&
+ mkdir -p origin/main &&
+ (
+ cd origin/main && git init &&
+ git submodule add ../sub &&
+ git commit -m "add sub"
+ ) &&
+ (
+ cd origin/sub &&
+ echo file1updated >file1 &&
+ git add file1 &&
+ git commit -m "file1 updated"
+ ) &&
+ git -C origin/main/sub pull &&
+ (
+ cd origin/main &&
+ git add sub &&
+ git commit -m "sub updated"
+ )
+'
+
+test_expect_success 'setup: clone' '
+ mkdir clone &&
+ git -C clone clone --recursive "$base_path/origin/main"
+'
+
+rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1")
+rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1")
+
+test_expect_success 'checkout main' '
+ mkdir default_checkout &&
+ git -C clone/main worktree add "$base_path/default_checkout/main" "$rev1_hash_main"
+'
+
+test_expect_failure 'can see submodule diffs just after checkout' '
+ git -C default_checkout/main diff --submodule master"^!" >out &&
+ grep "file1 updated" out
+'
+
+test_expect_success 'checkout main and initialize independent clones' '
+ mkdir fully_cloned_submodule &&
+ git -C clone/main worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main" &&
+ git -C fully_cloned_submodule/main submodule update
+'
+
+test_expect_success 'can see submodule diffs after independent cloning' '
+ git -C fully_cloned_submodule/main diff --submodule master"^!" >out &&
+ grep "file1 updated" out
+'
+
+test_expect_success 'checkout sub manually' '
+ mkdir linked_submodule &&
+ git -C clone/main worktree add "$base_path/linked_submodule/main" "$rev1_hash_main" &&
+ git -C clone/main/sub worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub"
+'
+
+test_expect_success 'can see submodule diffs after manual checkout of linked submodule' '
+ git -C linked_submodule/main diff --submodule master"^!" >out &&
+ grep "file1 updated" out
+'
+
+test_done