Skip to content

Commit 146b0ab

Browse files
committed
Merge branch 'sb/checkout-recurse-submodules' into maint
"git checkout --recurse-submodules" did not quite work with a submodule that itself has submodules. * sb/checkout-recurse-submodules: submodule: properly recurse for read-tree and checkout submodule: avoid auto-discovery in new working tree manipulator code submodule_move_head: reuse child_process structure for futher commands
2 parents 7633952 + 218c883 commit 146b0ab

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

submodule.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
13631363
{
13641364
struct child_process cp = CHILD_PROCESS_INIT;
13651365

1366-
prepare_submodule_repo_env_no_git_dir(&cp.env_array);
1366+
prepare_submodule_repo_env(&cp.env_array);
13671367

13681368
cp.git_cmd = 1;
13691369
argv_array_pushl(&cp.args, "diff-index", "--quiet",
@@ -1380,7 +1380,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
13801380
static void submodule_reset_index(const char *path)
13811381
{
13821382
struct child_process cp = CHILD_PROCESS_INIT;
1383-
prepare_submodule_repo_env_no_git_dir(&cp.env_array);
1383+
prepare_submodule_repo_env(&cp.env_array);
13841384

13851385
cp.git_cmd = 1;
13861386
cp.no_stdin = 1;
@@ -1438,15 +1438,15 @@ int submodule_move_head(const char *path,
14381438
}
14391439
}
14401440

1441-
prepare_submodule_repo_env_no_git_dir(&cp.env_array);
1441+
prepare_submodule_repo_env(&cp.env_array);
14421442

14431443
cp.git_cmd = 1;
14441444
cp.no_stdin = 1;
14451445
cp.dir = path;
14461446

14471447
argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
14481448
get_super_prefix_or_empty(), path);
1449-
argv_array_pushl(&cp.args, "read-tree", NULL);
1449+
argv_array_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
14501450

14511451
if (flags & SUBMODULE_MOVE_HEAD_DRY_RUN)
14521452
argv_array_push(&cp.args, "-n");
@@ -1468,15 +1468,16 @@ int submodule_move_head(const char *path,
14681468

14691469
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
14701470
if (new) {
1471-
struct child_process cp1 = CHILD_PROCESS_INIT;
1471+
child_process_init(&cp);
14721472
/* also set the HEAD accordingly */
1473-
cp1.git_cmd = 1;
1474-
cp1.no_stdin = 1;
1475-
cp1.dir = path;
1473+
cp.git_cmd = 1;
1474+
cp.no_stdin = 1;
1475+
cp.dir = path;
14761476

1477-
argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
1477+
prepare_submodule_repo_env(&cp.env_array);
1478+
argv_array_pushl(&cp.args, "update-ref", "HEAD", new, NULL);
14781479

1479-
if (run_command(&cp1)) {
1480+
if (run_command(&cp)) {
14801481
ret = -1;
14811482
goto out;
14821483
}

t/lib-submodule-update.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,6 @@ test_submodule_switch_recursing () {
787787
then
788788
RESULTDS=failure
789789
fi
790-
RESULTR=success
791-
if test "$KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED" = 1
792-
then
793-
RESULTR=failure
794-
fi
795790
RESULTOI=success
796791
if test "$KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED" = 1
797792
then
@@ -1003,7 +998,7 @@ test_submodule_switch_recursing () {
1003998
'
1004999

10051000
# recursing deeper than one level doesn't work yet.
1006-
test_expect_$RESULTR "$command: modified submodule updates submodule recursively" '
1001+
test_expect_success "$command: modified submodule updates submodule recursively" '
10071002
prolog &&
10081003
reset_work_tree_to_interested add_nested_sub &&
10091004
(

t/t1013-read-tree-submodule.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ test_description='read-tree can handle submodules'
55
. ./test-lib.sh
66
. "$TEST_DIRECTORY"/lib-submodule-update.sh
77

8-
KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
98
KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
109
KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1
1110

t/t2013-checkout-submodule.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
6464
'
6565

6666
KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
67-
KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
6867
test_submodule_switch_recursing "git checkout --recurse-submodules"
6968

7069
test_submodule_forced_switch_recursing "git checkout -f --recurse-submodules"

0 commit comments

Comments
 (0)