lib-submodule-update: prepend "git" to $command
Since all invocations of test_submodule_forced_switch() are git commands, automatically prepend "git" before invoking test_submodule_switch_common(). Similarly, many invocations of test_submodule_switch() are also git commands so automatically prepend "git" before invoking test_submodule_switch_common() as well. Finally, for invocations of test_submodule_switch() that invoke a custom function, rename the old function to test_submodule_switch_func(). This is necessary because in a future commit, we will be adding some logic that needs to distinguish between an invocation of a plain git comamnd and an invocation of a test helper function. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Jun 11, 2020 at 13:41 UTC
aa06180ac90984204e59ac74bb4e3a4d09037ac2
13 files changed
+34
-30
t/lib-submodule-update.sh
+9
-5
@@ -307,8 +307,8 @@ test_submodule_content () {
307
# to protect the history!
308
#
309
310
-# Internal function; use test_submodule_switch() or
311
-# test_submodule_forced_switch() instead.
310
+# Internal function; use test_submodule_switch_func(), test_submodule_switch(),
311
+# or test_submodule_forced_switch() instead.
312
test_submodule_switch_common () {
313
command="$1"
314
######################### Appearing submodule #########################
@@ -566,8 +566,8 @@ test_submodule_switch_common () {
566
# # Do something here that updates the worktree and index to match target,
567
# # but not any submodule directories.
568
# }
569
-# test_submodule_switch "my_func"
570
-test_submodule_switch () {
569
+# test_submodule_switch_func "my_func"
570
+test_submodule_switch_func () {
571
command="$1"
572
test_submodule_switch_common "$command"
573
@@ -587,12 +587,16 @@ test_submodule_switch () {
587
'
588
}
589
590
+test_submodule_switch () {
591
+ test_submodule_switch_func "git $1"
592
+}
593
+
594
# Same as test_submodule_switch(), except that throwing away local changes in
595
# the superproject is allowed.
596
test_submodule_forced_switch () {
597
command="$1"
598
KNOWN_FAILURE_FORCED_SWITCH_TESTS=1
595
- test_submodule_switch_common "$command"
599
+ test_submodule_switch_common "git $command"
600
601
# When forced, a file in the superproject does not prevent creating a
602
# submodule of the same name.
t/t1013-read-tree-submodule.sh
+2
-2
@@ -12,8 +12,8 @@ test_submodule_switch_recursing_with_args "read-tree -u -m"
12
13
test_submodule_forced_switch_recursing_with_args "read-tree -u --reset"
14
15
-test_submodule_switch "git read-tree -u -m"
15
+test_submodule_switch "read-tree -u -m"
16
17
-test_submodule_forced_switch "git read-tree -u --reset"
17
+test_submodule_forced_switch "read-tree -u --reset"
18
19
test_done
t/t2013-checkout-submodule.sh
+2
-2
@@ -68,8 +68,8 @@ test_submodule_switch_recursing_with_args "checkout"
68
69
test_submodule_forced_switch_recursing_with_args "checkout -f"
70
71
-test_submodule_switch "git checkout"
71
+test_submodule_switch "checkout"
72
73
-test_submodule_forced_switch "git checkout -f"
73
+test_submodule_forced_switch "checkout -f"
74
75
test_done
t/t3426-rebase-submodule.sh
+2
-2
@@ -20,7 +20,7 @@ git_rebase () {
20
git rebase "$1"
21
}
22
23
-test_submodule_switch "git_rebase"
23
+test_submodule_switch_func "git_rebase"
24
25
git_rebase_interactive () {
26
git status -su >expect &&
@@ -38,7 +38,7 @@ git_rebase_interactive () {
38
git rebase -i "$1"
39
}
40
41
-test_submodule_switch "git_rebase_interactive"
41
+test_submodule_switch_func "git_rebase_interactive"
42
43
test_expect_success 'rebase interactive ignores modified submodules' '
44
test_when_finished "rm -rf super sub" &&
t/t3512-cherry-pick-submodule.sh
+1
-1
@@ -7,7 +7,7 @@ test_description='cherry-pick can handle submodules'
7
8
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
9
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
10
-test_submodule_switch "git cherry-pick"
10
+test_submodule_switch "cherry-pick"
11
12
test_expect_success 'unrelated submodule/file conflict is ignored' '
13
test_create_repo sub &&
t/t3513-revert-submodule.sh
+1
-1
@@ -26,6 +26,6 @@ git_revert () {
26
}
27
28
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
29
-test_submodule_switch "git_revert"
29
+test_submodule_switch_func "git_revert"
30
31
test_done
t/t3906-stash-submodule.sh
+1
-1
@@ -19,7 +19,7 @@ git_stash () {
19
KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES=1
20
KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1
21
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
22
-test_submodule_switch "git_stash"
22
+test_submodule_switch_func "git_stash"
23
24
setup_basic () {
25
test_when_finished "rm -rf main sub" &&
t/t4137-apply-submodule.sh
+2
-2
@@ -9,12 +9,12 @@ apply_index () {
9
git diff --ignore-submodules=dirty "..$1" | git apply --index -
10
}
11
12
-test_submodule_switch "apply_index"
12
+test_submodule_switch_func "apply_index"
13
14
apply_3way () {
15
git diff --ignore-submodules=dirty "..$1" | git apply --3way -
16
}
17
18
-test_submodule_switch "apply_3way"
18
+test_submodule_switch_func "apply_3way"
19
20
test_done
t/t4255-am-submodule.sh
+2
-2
@@ -9,14 +9,14 @@ am () {
9
git format-patch --stdout --ignore-submodules=dirty "..$1" | git am -
10
}
11
12
-test_submodule_switch "am"
12
+test_submodule_switch_func "am"
13
14
am_3way () {
15
git format-patch --stdout --ignore-submodules=dirty "..$1" | git am --3way -
16
}
17
18
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
19
-test_submodule_switch "am_3way"
19
+test_submodule_switch_func "am_3way"
20
21
test_expect_success 'setup diff.submodule' '
22
test_commit one &&
t/t5572-pull-submodule.sh
+4
-4
@@ -17,21 +17,21 @@ git_pull () {
17
}
18
19
# pulls without conflicts
20
-test_submodule_switch "git_pull"
20
+test_submodule_switch_func "git_pull"
21
22
git_pull_ff () {
23
reset_branch_to_HEAD "$1" &&
24
git pull --ff
25
}
26
27
-test_submodule_switch "git_pull_ff"
27
+test_submodule_switch_func "git_pull_ff"
28
29
git_pull_ff_only () {
30
reset_branch_to_HEAD "$1" &&
31
git pull --ff-only
32
}
33
34
-test_submodule_switch "git_pull_ff_only"
34
+test_submodule_switch_func "git_pull_ff_only"
35
36
git_pull_noff () {
37
reset_branch_to_HEAD "$1" &&
@@ -40,7 +40,7 @@ git_pull_noff () {
40
41
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
42
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
43
-test_submodule_switch "git_pull_noff"
43
+test_submodule_switch_func "git_pull_noff"
44
45
test_expect_success 'pull --recurse-submodule setup' '
46
test_create_repo child &&
t/t6041-bisect-submodule.sh
+1
-1
@@ -27,6 +27,6 @@ git_bisect () {
27
git bisect bad $BAD
28
}
29
30
-test_submodule_switch "git_bisect"
30
+test_submodule_switch_func "git_bisect"
31
32
test_done
t/t7112-reset-submodule.sh
+3
-3
@@ -13,10 +13,10 @@ test_submodule_switch_recursing_with_args "reset --keep"
13
14
test_submodule_forced_switch_recursing_with_args "reset --hard"
15
16
-test_submodule_switch "git reset --keep"
16
+test_submodule_switch "reset --keep"
17
18
-test_submodule_switch "git reset --merge"
18
+test_submodule_switch "reset --merge"
19
20
-test_submodule_forced_switch "git reset --hard"
20
+test_submodule_forced_switch "reset --hard"
21
22
test_done
t/t7613-merge-submodule.sh
+4
-4
@@ -6,14 +6,14 @@ test_description='merge can handle submodules'
6
. "$TEST_DIRECTORY"/lib-submodule-update.sh
7
8
# merges without conflicts
9
-test_submodule_switch "git merge"
9
+test_submodule_switch "merge"
10
11
-test_submodule_switch "git merge --ff"
11
+test_submodule_switch "merge --ff"
12
13
-test_submodule_switch "git merge --ff-only"
13
+test_submodule_switch "merge --ff-only"
14
15
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
16
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
17
-test_submodule_switch "git merge --no-ff"
17
+test_submodule_switch "merge --no-ff"
18
19
test_done