]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rev-list: move `show_commit()` to the bottom
authorKarthik Nayak <karthik.188@gmail.com>
Thu, 26 Oct 2023 10:11:08 +0000 (12:11 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Nov 2023 03:07:18 +0000 (12:07 +0900)
The `show_commit()` function already depends on `finish_commit()`, and
in the upcoming commit, we'll also add a dependency on
`finish_object__ma()`. Since in C symbols must be declared before
they're used, let's move `show_commit()` below both `finish_commit()`
and `finish_object__ma()`, so the code is cleaner as a whole without the
need for declarations.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-list.c

index ea77489c38aa4be89c10a0ca44b77a59717befdc..98542e8b3ca341dd0fed2f18845ec8ec01deb3c3 100644 (file)
@@ -100,7 +100,48 @@ static off_t get_object_disk_usage(struct object *obj)
        return size;
 }
 
-static void finish_commit(struct commit *commit);
+static inline void finish_object__ma(struct object *obj)
+{
+       /*
+        * Whether or not we try to dynamically fetch missing objects
+        * from the server, we currently DO NOT have the object.  We
+        * can either print, allow (ignore), or conditionally allow
+        * (ignore) them.
+        */
+       switch (arg_missing_action) {
+       case MA_ERROR:
+               die("missing %s object '%s'",
+                   type_name(obj->type), oid_to_hex(&obj->oid));
+               return;
+
+       case MA_ALLOW_ANY:
+               return;
+
+       case MA_PRINT:
+               oidset_insert(&missing_objects, &obj->oid);
+               return;
+
+       case MA_ALLOW_PROMISOR:
+               if (is_promisor_object(&obj->oid))
+                       return;
+               die("unexpected missing %s object '%s'",
+                   type_name(obj->type), oid_to_hex(&obj->oid));
+               return;
+
+       default:
+               BUG("unhandled missing_action");
+               return;
+       }
+}
+
+static void finish_commit(struct commit *commit)
+{
+       free_commit_list(commit->parents);
+       commit->parents = NULL;
+       free_commit_buffer(the_repository->parsed_objects,
+                          commit);
+}
+
 static void show_commit(struct commit *commit, void *data)
 {
        struct rev_list_info *info = data;
@@ -219,48 +260,6 @@ static void show_commit(struct commit *commit, void *data)
        finish_commit(commit);
 }
 
-static void finish_commit(struct commit *commit)
-{
-       free_commit_list(commit->parents);
-       commit->parents = NULL;
-       free_commit_buffer(the_repository->parsed_objects,
-                          commit);
-}
-
-static inline void finish_object__ma(struct object *obj)
-{
-       /*
-        * Whether or not we try to dynamically fetch missing objects
-        * from the server, we currently DO NOT have the object.  We
-        * can either print, allow (ignore), or conditionally allow
-        * (ignore) them.
-        */
-       switch (arg_missing_action) {
-       case MA_ERROR:
-               die("missing %s object '%s'",
-                   type_name(obj->type), oid_to_hex(&obj->oid));
-               return;
-
-       case MA_ALLOW_ANY:
-               return;
-
-       case MA_PRINT:
-               oidset_insert(&missing_objects, &obj->oid);
-               return;
-
-       case MA_ALLOW_PROMISOR:
-               if (is_promisor_object(&obj->oid))
-                       return;
-               die("unexpected missing %s object '%s'",
-                   type_name(obj->type), oid_to_hex(&obj->oid));
-               return;
-
-       default:
-               BUG("unhandled missing_action");
-               return;
-       }
-}
-
 static int finish_object(struct object *obj, const char *name UNUSED,
                         void *cb_data)
 {