Skip to content

Commit 823bab0

Browse files
stefanbellergitster
authored andcommitted
submodule.c: uninitialized submodules are ignored in recursive commands
This was an oversight when working on the working tree modifying commands recursing into submodules. To test for uninitialized submodules, introduce another submodule "uninitialized_sub". Adding it via `submodule add` will activate the submodule in the preparation area (in create_lib_submodule_repo we setup all the things in submodule_update_repo), but the later tests will use a new testing repo that clones the preparation repo in which the new submodule is not initialized. By adding it to the branch "add_sub1", which is the starting point of all other branches, we have wide coverage. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd279e2 commit 823bab0

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

submodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,9 @@ int submodule_move_head(const char *path,
13331333
struct child_process cp = CHILD_PROCESS_INIT;
13341334
const struct submodule *sub;
13351335

1336+
if (!is_submodule_initialized(path))
1337+
return 0;
1338+
13361339
sub = submodule_from_path(null_sha1, path);
13371340

13381341
if (!sub)

t/lib-submodule-update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ create_lib_submodule_repo () {
7373

7474
git checkout -b "add_sub1" &&
7575
git submodule add ../submodule_update_sub1 sub1 &&
76+
git submodule add ../submodule_update_sub1 uninitialized_sub &&
7677
git config -f .gitmodules submodule.sub1.ignore all &&
7778
git config submodule.sub1.ignore all &&
7879
git add .gitmodules &&

0 commit comments

Comments
 (0)