]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: reorganize code for sh to C conversion
authorGlen Choo <chooglen@google.com>
Sat, 5 Mar 2022 00:13:51 +0000 (16:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Mar 2022 00:39:11 +0000 (16:39 -0800)
Introduce a function, update_submodule2(), that will implement the
functionality of run-update-procedure and its surrounding shell code in
submodule.sh. This name is temporary; it will replace update_submodule()
when the sh to C conversion is complete.

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c

index c11ee1ea2b97a1ab714a9ac2ed3a9e0f327fee8a..1b67a3887c8020174f1287f3cfaae748de0a1eca 100644 (file)
@@ -2452,6 +2452,16 @@ static int do_run_update_procedure(struct update_data *ud)
        return run_update_command(ud, subforce);
 }
 
+/*
+ * NEEDSWORK: As we convert "git submodule update" to C,
+ * update_submodule2() will invoke more and more functions, making it
+ * difficult to preserve the function ordering without forward
+ * declarations.
+ *
+ * When the conversion is complete, this forward declaration will be
+ * unnecessary and should be removed.
+ */
+static int update_submodule2(struct update_data *update_data);
 static void update_submodule(struct update_clone_data *ucd)
 {
        fprintf(stdout, "dummy %s %d\t%s\n",
@@ -2618,11 +2628,7 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
                                            &update_data.update_strategy);
 
        free(prefixed_path);
-
-       if (!oideq(&update_data.oid, &update_data.suboid) || update_data.force)
-               return do_run_update_procedure(&update_data);
-
-       return 3;
+       return update_submodule2(&update_data);
 }
 
 static int resolve_relative_path(int argc, const char **argv, const char *prefix)
@@ -3022,6 +3028,16 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
                                    force, reflog, quiet, track, dry_run);
        return 0;
 }
+
+/* NEEDSWORK: this is a temporary name until we delete update_submodule() */
+static int update_submodule2(struct update_data *update_data)
+{
+       if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force)
+               return do_run_update_procedure(update_data);
+
+       return 3;
+}
+
 struct add_data {
        const char *prefix;
        const char *branch;