Skip to content

Commit 42088e3

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: reorder remove_redundant_bitmaps()
The next commit will inline the call to `remove_redundant_bitmaps()` into `write_midx_included_packs()`. Reorder these two functions to avoid a forward declaration to `remove_redundant_bitmaps()`. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2fee63a commit 42088e3

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

builtin/repack.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,35 @@ static void midx_included_packs(struct string_list *include,
296296
strbuf_release(&buf);
297297
}
298298

299+
static void remove_redundant_bitmaps(struct string_list *include,
300+
const char *packdir)
301+
{
302+
struct strbuf path = STRBUF_INIT;
303+
struct string_list_item *item;
304+
size_t packdir_len;
305+
306+
strbuf_addstr(&path, packdir);
307+
strbuf_addch(&path, '/');
308+
packdir_len = path.len;
309+
310+
/*
311+
* Remove any pack bitmaps corresponding to packs which are now
312+
* included in the MIDX.
313+
*/
314+
for_each_string_list_item(item, include) {
315+
strbuf_addstr(&path, item->string);
316+
strbuf_strip_suffix(&path, ".idx");
317+
strbuf_addstr(&path, ".bitmap");
318+
319+
if (unlink(path.buf) && errno != ENOENT)
320+
warning_errno(_("could not remove stale bitmap: %s"),
321+
path.buf);
322+
323+
strbuf_setlen(&path, packdir_len);
324+
}
325+
strbuf_release(&path);
326+
}
327+
299328
static int write_midx_included_packs(struct repack_write_midx_opts *opts)
300329
{
301330
struct child_process cmd = CHILD_PROCESS_INIT;
@@ -373,35 +402,6 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)
373402
return finish_command(&cmd);
374403
}
375404

376-
static void remove_redundant_bitmaps(struct string_list *include,
377-
const char *packdir)
378-
{
379-
struct strbuf path = STRBUF_INIT;
380-
struct string_list_item *item;
381-
size_t packdir_len;
382-
383-
strbuf_addstr(&path, packdir);
384-
strbuf_addch(&path, '/');
385-
packdir_len = path.len;
386-
387-
/*
388-
* Remove any pack bitmaps corresponding to packs which are now
389-
* included in the MIDX.
390-
*/
391-
for_each_string_list_item(item, include) {
392-
strbuf_addstr(&path, item->string);
393-
strbuf_strip_suffix(&path, ".idx");
394-
strbuf_addstr(&path, ".bitmap");
395-
396-
if (unlink(path.buf) && errno != ENOENT)
397-
warning_errno(_("could not remove stale bitmap: %s"),
398-
path.buf);
399-
400-
strbuf_setlen(&path, packdir_len);
401-
}
402-
strbuf_release(&path);
403-
}
404-
405405
static int finish_pack_objects_cmd(const struct git_hash_algo *algop,
406406
struct child_process *cmd,
407407
struct string_list *names,

0 commit comments

Comments
 (0)