@@ -2794,18 +2794,12 @@ 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 struct submodule *sub;
- const char *path;
const char *cw;
struct repository subrepo;
- if (argc != 2)
- BUG("submodule--helper ensure-core-worktree <path>");
-
- path = argv[1];
-
sub = submodule_from_path(the_repository, null_oid(), path);
if (!sub)
BUG("We could get the submodule handle before?");
@@ -2829,6 +2823,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;
}
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(-)