t7410: update to new style
While at it fix a typo (s/independed/independent) and make sure git is not in a chain of pipes. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Aug 15, 2018 at 19:30 UTC
31158c7efc9bb91ebee9083d65b178d9f211d7d2
1 file changed
+58
-41
t/t7410-submodule-checkout-to.sh
+58
-41
@@ -6,55 +6,72 @@ test_description='Combination of submodules and multiple workdirs'
6
7
base_path=$(pwd -P)
8
9
-test_expect_success 'setup: make origin' \
10
- 'mkdir -p origin/sub && ( cd origin/sub && git init &&
11
- echo file1 >file1 &&
12
- git add file1 &&
13
- git commit -m file1 ) &&
14
- mkdir -p origin/main && ( cd origin/main && git init &&
15
- git submodule add ../sub &&
16
- git commit -m "add sub" ) &&
17
- ( cd origin/sub &&
18
- echo file1updated >file1 &&
19
- git add file1 &&
20
- git commit -m "file1 updated" ) &&
21
- ( cd origin/main/sub && git pull ) &&
22
- ( cd origin/main &&
23
- git add sub &&
24
- git commit -m "sub updated" )'
25
-
26
-test_expect_success 'setup: clone' \
27
- 'mkdir clone && ( cd clone &&
28
- git clone --recursive "$base_path/origin/main")'
9
+test_expect_success 'setup: make origin' '
10
+ mkdir -p origin/sub &&
11
+ (
12
+ cd origin/sub && git init &&
13
+ echo file1 >file1 &&
14
+ git add file1 &&
15
+ git commit -m file1
16
+ ) &&
17
+ mkdir -p origin/main &&
18
+ (
19
+ cd origin/main && git init &&
20
+ git submodule add ../sub &&
21
+ git commit -m "add sub"
22
+ ) &&
23
+ (
24
+ cd origin/sub &&
25
+ echo file1updated >file1 &&
26
+ git add file1 &&
27
+ git commit -m "file1 updated"
28
+ ) &&
29
+ git -C origin/main/sub pull &&
30
+ (
31
+ cd origin/main &&
32
+ git add sub &&
33
+ git commit -m "sub updated"
34
+ )
35
+'
36
+
37
+test_expect_success 'setup: clone' '
38
+ mkdir clone &&
39
+ git -C clone clone --recursive "$base_path/origin/main"
40
+'
41
42
rev1_hash_main=$(git --git-dir=origin/main/.git show --pretty=format:%h -q "HEAD~1")
43
rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1")
44
33
-test_expect_success 'checkout main' \
34
- 'mkdir default_checkout &&
35
- (cd clone/main &&
36
- git worktree add "$base_path/default_checkout/main" "$rev1_hash_main")'
45
+test_expect_success 'checkout main' '
46
+ mkdir default_checkout &&
47
+ git -C clone/main worktree add "$base_path/default_checkout/main" "$rev1_hash_main"
48
+'
49
38
-test_expect_failure 'can see submodule diffs just after checkout' \
39
- '(cd default_checkout/main && git diff --submodule master"^!" | grep "file1 updated")'
50
+test_expect_failure 'can see submodule diffs just after checkout' '
51
+ git -C default_checkout/main diff --submodule master"^!" >out &&
52
+ grep "file1 updated" out
53
+'
54
41
-test_expect_success 'checkout main and initialize independed clones' \
42
- 'mkdir fully_cloned_submodule &&
43
- (cd clone/main &&
44
- git worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") &&
45
- (cd fully_cloned_submodule/main && git submodule update)'
55
+test_expect_success 'checkout main and initialize independent clones' '
56
+ mkdir fully_cloned_submodule &&
57
+ git -C clone/main worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main" &&
58
+ git -C fully_cloned_submodule/main submodule update
59
+'
60
47
-test_expect_success 'can see submodule diffs after independed cloning' \
48
- '(cd fully_cloned_submodule/main && git diff --submodule master"^!" | grep "file1 updated")'
61
+test_expect_success 'can see submodule diffs after independent cloning' '
62
+ git -C fully_cloned_submodule/main diff --submodule master"^!" >out &&
63
+ grep "file1 updated" out
64
+'
65
50
-test_expect_success 'checkout sub manually' \
51
- 'mkdir linked_submodule &&
52
- (cd clone/main &&
53
- git worktree add "$base_path/linked_submodule/main" "$rev1_hash_main") &&
54
- (cd clone/main/sub &&
55
- git worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub")'
66
+test_expect_success 'checkout sub manually' '
67
+ mkdir linked_submodule &&
68
+ git -C clone/main worktree add "$base_path/linked_submodule/main" "$rev1_hash_main" &&
69
+ git -C clone/main/sub worktree add "$base_path/linked_submodule/main/sub" "$rev1_hash_sub"
70
+'
71
57
-test_expect_success 'can see submodule diffs after manual checkout of linked submodule' \
58
- '(cd linked_submodule/main && git diff --submodule master"^!" | grep "file1 updated")'
72
+test_expect_success 'can see submodule diffs after manual checkout of linked submodule' '
73
+ git -C linked_submodule/main diff --submodule master"^!" >out &&
74
+ grep "file1 updated" out
75
+'
76
77
test_done