[PATCH v3 1/9] submodule--helper: split up ensure_core_worktree()
- From
Atharva Raykar <raykar.ath@gmail.com>
- Date
- Oct 13, 2021, 05:17 UTC
- Message-ID
- <20211013051805.45662-2-raykar.ath@gmail.com>
- In-Reply-To
- <20211013051805.45662-1-raykar.ath@gmail.com>
Let's split up `ensure_core_worktree()` so that we can call it from C code without needing to deal with command line arguments.
Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Shourya Shukla <periperidip@gmail.com> Signed-off-by: Atharva Raykar <raykar.ath@gmail.com> --- builtin/submodule--helper.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 88ce6be69c..764fcb7dba 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2764,17 +2764,11 @@ static int push_check(int argc, const char **argv, const char *prefix) return 0; } -static int ensure_core_worktree(int argc, const char **argv, const char *prefix) +static void do_ensure_core_worktree(const char *path) { - const char *path; const char *cw; struct repository subrepo; - if (argc != 2) - BUG("submodule--helper ensure-core-worktree <path>"); - - path = argv[1]; - if (repo_submodule_init(&subrepo, the_repository, path, null_oid())) die(_("could not get a repository handle for submodule '%s'"), path); @@ -2794,6 +2788,17 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix) free(abs_path); strbuf_release(&sb); } +} + +static int ensure_core_worktree(int argc, const char **argv, const char *prefix) +{ + const char *path; + + if (argc != 2) + BUG("submodule--helper ensure-core-worktree <path>"); + + path = argv[1]; + do_ensure_core_worktree(path); return 0; }
-- 2.32.0