Skip to content

Commit aa06180

Browse files
Denton-Lgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent add2452 commit aa06180

13 files changed

+34
-30
lines changed

t/lib-submodule-update.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ test_submodule_content () {
307307
# to protect the history!
308308
#
309309

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.
312312
test_submodule_switch_common () {
313313
command="$1"
314314
######################### Appearing submodule #########################
@@ -566,8 +566,8 @@ test_submodule_switch_common () {
566566
# # Do something here that updates the worktree and index to match target,
567567
# # but not any submodule directories.
568568
# }
569-
# test_submodule_switch "my_func"
570-
test_submodule_switch () {
569+
# test_submodule_switch_func "my_func"
570+
test_submodule_switch_func () {
571571
command="$1"
572572
test_submodule_switch_common "$command"
573573

@@ -587,12 +587,16 @@ test_submodule_switch () {
587587
'
588588
}
589589

590+
test_submodule_switch () {
591+
test_submodule_switch_func "git $1"
592+
}
593+
590594
# Same as test_submodule_switch(), except that throwing away local changes in
591595
# the superproject is allowed.
592596
test_submodule_forced_switch () {
593597
command="$1"
594598
KNOWN_FAILURE_FORCED_SWITCH_TESTS=1
595-
test_submodule_switch_common "$command"
599+
test_submodule_switch_common "git $command"
596600

597601
# When forced, a file in the superproject does not prevent creating a
598602
# submodule of the same name.

t/t1013-read-tree-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ test_submodule_switch_recursing_with_args "read-tree -u -m"
1212

1313
test_submodule_forced_switch_recursing_with_args "read-tree -u --reset"
1414

15-
test_submodule_switch "git read-tree -u -m"
15+
test_submodule_switch "read-tree -u -m"
1616

17-
test_submodule_forced_switch "git read-tree -u --reset"
17+
test_submodule_forced_switch "read-tree -u --reset"
1818

1919
test_done

t/t2013-checkout-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ test_submodule_switch_recursing_with_args "checkout"
6868

6969
test_submodule_forced_switch_recursing_with_args "checkout -f"
7070

71-
test_submodule_switch "git checkout"
71+
test_submodule_switch "checkout"
7272

73-
test_submodule_forced_switch "git checkout -f"
73+
test_submodule_forced_switch "checkout -f"
7474

7575
test_done

t/t3426-rebase-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ git_rebase () {
2020
git rebase "$1"
2121
}
2222

23-
test_submodule_switch "git_rebase"
23+
test_submodule_switch_func "git_rebase"
2424

2525
git_rebase_interactive () {
2626
git status -su >expect &&
@@ -38,7 +38,7 @@ git_rebase_interactive () {
3838
git rebase -i "$1"
3939
}
4040

41-
test_submodule_switch "git_rebase_interactive"
41+
test_submodule_switch_func "git_rebase_interactive"
4242

4343
test_expect_success 'rebase interactive ignores modified submodules' '
4444
test_when_finished "rm -rf super sub" &&

t/t3512-cherry-pick-submodule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='cherry-pick can handle submodules'
77

88
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
99
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
10-
test_submodule_switch "git cherry-pick"
10+
test_submodule_switch "cherry-pick"
1111

1212
test_expect_success 'unrelated submodule/file conflict is ignored' '
1313
test_create_repo sub &&

t/t3513-revert-submodule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ git_revert () {
2626
}
2727

2828
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
29-
test_submodule_switch "git_revert"
29+
test_submodule_switch_func "git_revert"
3030

3131
test_done

t/t3906-stash-submodule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ git_stash () {
1919
KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES=1
2020
KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1
2121
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
22-
test_submodule_switch "git_stash"
22+
test_submodule_switch_func "git_stash"
2323

2424
setup_basic () {
2525
test_when_finished "rm -rf main sub" &&

t/t4137-apply-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ apply_index () {
99
git diff --ignore-submodules=dirty "..$1" | git apply --index -
1010
}
1111

12-
test_submodule_switch "apply_index"
12+
test_submodule_switch_func "apply_index"
1313

1414
apply_3way () {
1515
git diff --ignore-submodules=dirty "..$1" | git apply --3way -
1616
}
1717

18-
test_submodule_switch "apply_3way"
18+
test_submodule_switch_func "apply_3way"
1919

2020
test_done

t/t4255-am-submodule.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ am () {
99
git format-patch --stdout --ignore-submodules=dirty "..$1" | git am -
1010
}
1111

12-
test_submodule_switch "am"
12+
test_submodule_switch_func "am"
1313

1414
am_3way () {
1515
git format-patch --stdout --ignore-submodules=dirty "..$1" | git am --3way -
1616
}
1717

1818
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
19-
test_submodule_switch "am_3way"
19+
test_submodule_switch_func "am_3way"
2020

2121
test_expect_success 'setup diff.submodule' '
2222
test_commit one &&

t/t5572-pull-submodule.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ git_pull () {
1717
}
1818

1919
# pulls without conflicts
20-
test_submodule_switch "git_pull"
20+
test_submodule_switch_func "git_pull"
2121

2222
git_pull_ff () {
2323
reset_branch_to_HEAD "$1" &&
2424
git pull --ff
2525
}
2626

27-
test_submodule_switch "git_pull_ff"
27+
test_submodule_switch_func "git_pull_ff"
2828

2929
git_pull_ff_only () {
3030
reset_branch_to_HEAD "$1" &&
3131
git pull --ff-only
3232
}
3333

34-
test_submodule_switch "git_pull_ff_only"
34+
test_submodule_switch_func "git_pull_ff_only"
3535

3636
git_pull_noff () {
3737
reset_branch_to_HEAD "$1" &&
@@ -40,7 +40,7 @@ git_pull_noff () {
4040

4141
KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
4242
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"
4444

4545
test_expect_success 'pull --recurse-submodule setup' '
4646
test_create_repo child &&

0 commit comments

Comments
 (0)