diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2021-09-09 11:47:28 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-09 14:09:30 -0700 |
commit | 8eb8dcf94643ca6e7c3f040f3e0bf96e11c7ae47 (patch) | |
tree | f7e2ee9926bed0f5382f492687ca830a599c993c /builtin | |
parent | submodule: remove unnecessary unabsorbed fallback (diff) | |
download | tgif-8eb8dcf94643ca6e7c3f040f3e0bf96e11c7ae47.tar.xz |
repository: support unabsorbed in repo_submodule_init
In preparation for a subsequent commit that migrates code using
add_submodule_odb() to repo_submodule_init(), teach
repo_submodule_init() to support submodules with unabsorbed gitdirs.
(See the documentation for "git submodule absorbgitdirs" for more
information about absorbed and unabsorbed gitdirs.)
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 5 | ||||
-rw-r--r-- | builtin/ls-files.c | 4 | ||||
-rw-r--r-- | builtin/submodule--helper.c | 7 |
3 files changed, 3 insertions, 13 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 51278b01fa..8af5249a7b 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -433,17 +433,14 @@ static int grep_submodule(struct grep_opt *opt, { struct repository *subrepo; struct repository *superproject = opt->repo; - const struct submodule *sub; struct grep_opt subopt; int hit = 0; - sub = submodule_from_path(superproject, null_oid(), path); - if (!is_submodule_active(superproject, path)) return 0; subrepo = xmalloc(sizeof(*subrepo)); - if (repo_submodule_init(subrepo, superproject, sub)) { + if (repo_submodule_init(subrepo, superproject, path, null_oid())) { free(subrepo); return 0; } diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 29a26ad8ae..ec19bf54b2 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -209,10 +209,8 @@ static void show_submodule(struct repository *superproject, struct dir_struct *dir, const char *path) { struct repository subrepo; - const struct submodule *sub = submodule_from_path(superproject, - null_oid(), path); - if (repo_submodule_init(&subrepo, superproject, sub)) + if (repo_submodule_init(&subrepo, superproject, path, null_oid())) return; if (repo_read_index(&subrepo) < 0) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index ef2776a9e4..6718f202db 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2540,7 +2540,6 @@ static int push_check(int argc, const char **argv, const char *prefix) static int ensure_core_worktree(int argc, const char **argv, const char *prefix) { - const struct submodule *sub; const char *path; const char *cw; struct repository subrepo; @@ -2550,11 +2549,7 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix) path = argv[1]; - sub = submodule_from_path(the_repository, null_oid(), path); - if (!sub) - BUG("We could get the submodule handle before?"); - - if (repo_submodule_init(&subrepo, the_repository, sub)) + if (repo_submodule_init(&subrepo, the_repository, path, null_oid())) die(_("could not get a repository handle for submodule '%s'"), path); if (!repo_config_get_string_tmp(&subrepo, "core.worktree", &cw)) { |