Skip to content

Commit b495292

Browse files
KarthikNayakgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca556f4 commit b495292

File tree

1 file changed

+42
-43
lines changed

1 file changed

+42
-43
lines changed

builtin/rev-list.c

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,48 @@ static off_t get_object_disk_usage(struct object *obj)
100100
return size;
101101
}
102102

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+
104145
static void show_commit(struct commit *commit, void *data)
105146
{
106147
struct rev_list_info *info = data;
@@ -219,48 +260,6 @@ static void show_commit(struct commit *commit, void *data)
219260
finish_commit(commit);
220261
}
221262

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-
264263
static int finish_object(struct object *obj, const char *name UNUSED,
265264
void *cb_data)
266265
{

0 commit comments

Comments
 (0)