Skip to content

Commit 89f64f7

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 87ce294 commit 89f64f7

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
@@ -3677,6 +3677,17 @@ static void read_packs_list_from_stdin(void)
36773677
string_list_clear(&exclude_packs, 0);
36783678
}
36793679

3680+
static void add_unreachable_loose_objects(void);
3681+
3682+
static void read_stdin_packs(int rev_list_unpacked)
3683+
{
3684+
/* avoids adding objects in excluded packs */
3685+
ignore_packed_keep_in_core = 1;
3686+
read_packs_list_from_stdin();
3687+
if (rev_list_unpacked)
3688+
add_unreachable_loose_objects();
3689+
}
3690+
36803691
static void add_cruft_object_entry(const struct object_id *oid, enum object_type type,
36813692
struct packed_git *pack, off_t offset,
36823693
const char *name, uint32_t mtime)
@@ -3772,7 +3783,6 @@ static void mark_pack_kept_in_core(struct string_list *packs, unsigned keep)
37723783
}
37733784
}
37743785

3775-
static void add_unreachable_loose_objects(void);
37763786
static void add_objects_in_unpacked_packs(void);
37773787

37783788
static void enumerate_cruft_objects(void)
@@ -4779,11 +4789,7 @@ int cmd_pack_objects(int argc,
47794789
progress_state = start_progress(the_repository,
47804790
_("Enumerating objects"), 0);
47814791
if (stdin_packs) {
4782-
/* avoids adding objects in excluded packs */
4783-
ignore_packed_keep_in_core = 1;
4784-
read_packs_list_from_stdin();
4785-
if (rev_list_unpacked)
4786-
add_unreachable_loose_objects();
4792+
read_stdin_packs(rev_list_unpacked);
47874793
} else if (cruft) {
47884794
read_cruft_objects();
47894795
} else if (!use_internal_rev_list) {

0 commit comments

Comments
 (0)