Skip to content

Commit 67e1a78

Browse files
ttaylorrgitster
authored andcommitted
pack-objects: factor out handling '--stdin-packs'
At the bottom of cmd_pack_objects() we check which mode the command is running in (e.g., generating a cruft pack, handling '--stdin-packs', using the internal rev-list, etc.) and handle the mode appropriately. The '--stdin-packs' case is handled inline (dating back to its introduction in 339bce2 (builtin/pack-objects.c: add '--stdin-packs' option, 2021-02-22)) since it is relatively short. Extract the body of "if (stdin_packs)" into its own function to prepare for the implementation to become lengthier in a following commit. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9809d4a commit 67e1a78

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

builtin/pack-objects.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,6 +3909,17 @@ static void read_packs_list_from_stdin(void)
39093909
string_list_clear(&exclude_packs, 0);
39103910
}
39113911

3912+
static void add_unreachable_loose_objects(void);
3913+
3914+
static void read_stdin_packs(int rev_list_unpacked)
3915+
{
3916+
/* avoids adding objects in excluded packs */
3917+
ignore_packed_keep_in_core = 1;
3918+
read_packs_list_from_stdin();
3919+
if (rev_list_unpacked)
3920+
add_unreachable_loose_objects();
3921+
}
3922+
39123923
static void add_cruft_object_entry(const struct object_id *oid, enum object_type type,
39133924
struct packed_git *pack, off_t offset,
39143925
const char *name, uint32_t mtime)
@@ -4004,7 +4015,6 @@ static void mark_pack_kept_in_core(struct string_list *packs, unsigned keep)
40044015
}
40054016
}
40064017

4007-
static void add_unreachable_loose_objects(void);
40084018
static void add_objects_in_unpacked_packs(void);
40094019

40104020
static void enumerate_cruft_objects(void)
@@ -5135,11 +5145,7 @@ int cmd_pack_objects(int argc,
51355145
progress_state = start_progress(the_repository,
51365146
_("Enumerating objects"), 0);
51375147
if (stdin_packs) {
5138-
/* avoids adding objects in excluded packs */
5139-
ignore_packed_keep_in_core = 1;
5140-
read_packs_list_from_stdin();
5141-
if (rev_list_unpacked)
5142-
add_unreachable_loose_objects();
5148+
read_stdin_packs(rev_list_unpacked);
51435149
} else if (cruft) {
51445150
read_cruft_objects();
51455151
} else if (!use_internal_rev_list) {

0 commit comments

Comments
 (0)