Skip to content

Commit 5df5106

Browse files
jonathantanmygitster
authored andcommitted
submodule: remove unnecessary unabsorbed fallback
In get_submodule_repo_for(), there is a fallback code path for the case in which a submodule has an unabsorbed gitdir. (See the documentation for "git submodule absorbgitdirs" for more information about absorbed and unabsorbed gitdirs.) However, this code path is unnecessary, because such submodules are already handled: when the fetch_task is created in fetch_task_create(), it will create its own struct submodule with a path and name, and repo_submodule_init() can handle such a struct. This fallback was introduced in 26f80cc ("submodule: migrate get_next_submodule to use repository structs", 2018-12-05). It was unnecessary even then, but perhaps it escaped notice because its parent commit d5498e0 ("repository: repo_submodule_init to take a submodule struct", 2018-12-05) was the one that taught repo_submodule_init() to handle such created structs. Before, it took a path and always checked .gitmodules, so it truly would have failed if there were no entry in .gitmodules. (Note to reviewers: in 26f80cc, the "own struct submodule" I mentioned is in get_next_submodule(), not fetch_task_create().) Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 18a2f66 commit 5df5106

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

submodule.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,19 +1409,8 @@ static struct repository *get_submodule_repo_for(struct repository *r,
14091409
struct repository *ret = xmalloc(sizeof(*ret));
14101410

14111411
if (repo_submodule_init(ret, r, sub)) {
1412-
/*
1413-
* No entry in .gitmodules? Technically not a submodule,
1414-
* but historically we supported repositories that happen to be
1415-
* in-place where a gitlink is. Keep supporting them.
1416-
*/
1417-
struct strbuf gitdir = STRBUF_INIT;
1418-
strbuf_repo_worktree_path(&gitdir, r, "%s/.git", sub->path);
1419-
if (repo_init(ret, gitdir.buf, NULL)) {
1420-
strbuf_release(&gitdir);
1421-
free(ret);
1422-
return NULL;
1423-
}
1424-
strbuf_release(&gitdir);
1412+
free(ret);
1413+
return NULL;
14251414
}
14261415

14271416
return ret;

0 commit comments

Comments
 (0)