rev-list: move `show_commit()` to the bottom
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>
Karthik Nayak committed
Oct 26, 2023 at 12:11 UTC
b49529230d512c9a9551e064e3181bc8c1264880
1 file changed
+42
-43
builtin/rev-list.c
+42
-43
@@ -100,7 +100,48 @@ static off_t get_object_disk_usage(struct object *obj)
100
return size;
101
}
102
103
-static void finish_commit(struct commit *commit);
103
+static inline void finish_object__ma(struct object *obj)
104
+{
105
+ /*
106
+ * Whether or not we try to dynamically fetch missing objects
107
+ * from the server, we currently DO NOT have the object. We
108
+ * can either print, allow (ignore), or conditionally allow
109
+ * (ignore) them.
110
+ */
111
+ switch (arg_missing_action) {
112
+ case MA_ERROR:
113
+ die("missing %s object '%s'",
114
+ type_name(obj->type), oid_to_hex(&obj->oid));
115
+ return;
116
+
117
+ case MA_ALLOW_ANY:
118
+ return;
119
+
120
+ case MA_PRINT:
121
+ oidset_insert(&missing_objects, &obj->oid);
122
+ return;
123
+
124
+ case MA_ALLOW_PROMISOR:
125
+ if (is_promisor_object(&obj->oid))
126
+ return;
127
+ die("unexpected missing %s object '%s'",
128
+ type_name(obj->type), oid_to_hex(&obj->oid));
129
+ return;
130
+
131
+ default:
132
+ BUG("unhandled missing_action");
133
+ return;
134
+ }
135
+}
136
+
137
+static void finish_commit(struct commit *commit)
138
+{
139
+ free_commit_list(commit->parents);
140
+ commit->parents = NULL;
141
+ free_commit_buffer(the_repository->parsed_objects,
142
+ commit);
143
+}
144
+
145
static void show_commit(struct commit *commit, void *data)
146
{
147
struct rev_list_info *info = data;
@@ -219,48 +260,6 @@ static void show_commit(struct commit *commit, void *data)
260
finish_commit(commit);
261
}
262
222
-static void finish_commit(struct commit *commit)
223
-{
224
- free_commit_list(commit->parents);
225
- commit->parents = NULL;
226
- free_commit_buffer(the_repository->parsed_objects,
227
- commit);
228
-}
229
-
230
-static inline void finish_object__ma(struct object *obj)
231
-{
232
- /*
233
- * Whether or not we try to dynamically fetch missing objects
234
- * from the server, we currently DO NOT have the object. We
235
- * can either print, allow (ignore), or conditionally allow
236
- * (ignore) them.
237
- */
238
- switch (arg_missing_action) {
239
- case MA_ERROR:
240
- die("missing %s object '%s'",
241
- type_name(obj->type), oid_to_hex(&obj->oid));
242
- return;
243
-
244
- case MA_ALLOW_ANY:
245
- return;
246
-
247
- case MA_PRINT:
248
- oidset_insert(&missing_objects, &obj->oid);
249
- return;
250
-
251
- case MA_ALLOW_PROMISOR:
252
- if (is_promisor_object(&obj->oid))
253
- return;
254
- die("unexpected missing %s object '%s'",
255
- type_name(obj->type), oid_to_hex(&obj->oid));
256
- return;
257
-
258
- default:
259
- BUG("unhandled missing_action");
260
- return;
261
- }
262
-}
263
-
263
static int finish_object(struct object *obj, const char *name UNUSED,
264
void *cb_data)
265
{