Skip to content

Commit f1101ce

Browse files
committed
Merge branch 'sb/checkout-recurse-submodules'
"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 31fb6f4 + 218c883 commit f1101ce

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
@@ -1356,7 +1356,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
13561356
{
13571357
struct child_process cp = CHILD_PROCESS_INIT;
13581358

1359-
prepare_submodule_repo_env_no_git_dir(&cp.env_array);
1359+
prepare_submodule_repo_env(&cp.env_array);
13601360

13611361
cp.git_cmd = 1;
13621362
argv_array_pushl(&cp.args, "diff-index", "--quiet",
@@ -1373,7 +1373,7 @@ static int submodule_has_dirty_index(const struct submodule *sub)
13731373
static void submodule_reset_index(const char *path)
13741374
{
13751375
struct child_process cp = CHILD_PROCESS_INIT;
1376-
prepare_submodule_repo_env_no_git_dir(&cp.env_array);
1376+
prepare_submodule_repo_env(&cp.env_array);
13771377

13781378
cp.git_cmd = 1;
13791379
cp.no_stdin = 1;
@@ -1454,15 +1454,15 @@ int submodule_move_head(const char *path,
14541454
}
14551455
}
14561456

1457-
prepare_submodule_repo_env_no_git_dir(&cp.env_array);
1457+
prepare_submodule_repo_env(&cp.env_array);
14581458

14591459
cp.git_cmd = 1;
14601460
cp.no_stdin = 1;
14611461
cp.dir = path;
14621462

14631463
argv_array_pushf(&cp.args, "--super-prefix=%s%s/",
14641464
get_super_prefix_or_empty(), path);
1465-
argv_array_pushl(&cp.args, "read-tree", NULL);
1465+
argv_array_pushl(&cp.args, "read-tree", "--recurse-submodules", NULL);
14661466

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

14851485
if (!(flags & SUBMODULE_MOVE_HEAD_DRY_RUN)) {
14861486
if (new) {
1487-
struct child_process cp1 = CHILD_PROCESS_INIT;
1487+
child_process_init(&cp);
14881488
/* also set the HEAD accordingly */
1489-
cp1.git_cmd = 1;
1490-
cp1.no_stdin = 1;
1491-
cp1.dir = path;
1489+
cp.git_cmd = 1;
1490+
cp.no_stdin = 1;
1491+
cp.dir = path;
14921492

1493-
argv_array_pushl(&cp1.args, "update-ref", "HEAD", new, NULL);
1493+
prepare_submodule_repo_env(&cp.env_array);
1494+
argv_array_pushl(&cp.args, "update-ref", "HEAD", new, NULL);
14941495

1495-
if (run_command(&cp1)) {
1496+
if (run_command(&cp)) {
14961497
ret = -1;
14971498
goto out;
14981499
}

t/lib-submodule-update.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,6 @@ test_submodule_switch_recursing () {
788788
then
789789
RESULTDS=failure
790790
fi
791-
RESULTR=success
792-
if test "$KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED" = 1
793-
then
794-
RESULTR=failure
795-
fi
796791
RESULTOI=success
797792
if test "$KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED" = 1
798793
then
@@ -1004,7 +999,7 @@ test_submodule_switch_recursing () {
1004999
'
10051000

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

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)