4444#include "blob.h"
4545#include "tree.h"
4646#include "path-walk.h"
47+ #include "trace2.h"
4748
4849/*
4950 * Objects we are going to pack are collected in the `to_pack` structure.
@@ -187,8 +188,14 @@ static inline void oe_set_delta_size(struct packing_data *pack,
187188#define SET_DELTA_SIBLING (obj , val ) oe_set_delta_sibling(&to_pack, obj, val)
188189
189190static const char * const pack_usage [] = {
190- N_ ("git pack-objects --stdout [<options>] [< <ref-list> | < <object-list>]" ),
191- N_ ("git pack-objects [<options>] <base-name> [< <ref-list> | < <object-list>]" ),
191+ N_ ("git pack-objects [-q | --progress | --all-progress] [--all-progress-implied]\n"
192+ " [--no-reuse-delta] [--delta-base-offset] [--non-empty]\n"
193+ " [--local] [--incremental] [--window=<n>] [--depth=<n>]\n"
194+ " [--revs [--unpacked | --all]] [--keep-pack=<pack-name>]\n"
195+ " [--cruft] [--cruft-expiration=<time>]\n"
196+ " [--stdout [--filter=<filter-spec>] | <base-name>]\n"
197+ " [--shallow] [--keep-true-parents] [--[no-]sparse]\n"
198+ " [--name-hash-version=<n>] [--path-walk] < <object-list>" ),
192199 NULL
193200};
194201
@@ -203,6 +210,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
203210static timestamp_t unpack_unreachable_expiration ;
204211static int pack_loose_unreachable ;
205212static int cruft ;
213+ static int shallow = 0 ;
206214static timestamp_t cruft_expiration ;
207215static int local ;
208216static int have_non_local_packs ;
@@ -3291,6 +3299,9 @@ static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, cons
32913299static int should_attempt_deltas (struct object_entry * entry )
32923300{
32933301 if (DELTA (entry ))
3302+ /* This happens if we decided to reuse existing
3303+ * delta from a pack. "reuse_delta &&" is implied.
3304+ */
32943305 return 0 ;
32953306
32963307 if (!entry -> type_valid ||
@@ -3315,16 +3326,16 @@ static int should_attempt_deltas(struct object_entry *entry)
33153326 return 1 ;
33163327}
33173328
3318- static void find_deltas_for_region (struct object_entry * list UNUSED ,
3329+ static void find_deltas_for_region (struct object_entry * list ,
33193330 struct packing_region * region ,
33203331 unsigned int * processed )
33213332{
33223333 struct object_entry * * delta_list ;
3323- uint32_t delta_list_nr = 0 ;
3334+ unsigned int delta_list_nr = 0 ;
33243335
33253336 ALLOC_ARRAY (delta_list , region -> nr );
3326- for (uint32_t i = 0 ; i < region -> nr ; i ++ ) {
3327- struct object_entry * entry = to_pack . objects + region -> start + i ;
3337+ for (size_t i = 0 ; i < region -> nr ; i ++ ) {
3338+ struct object_entry * entry = list + region -> start + i ;
33283339 if (should_attempt_deltas (entry ))
33293340 delta_list [delta_list_nr ++ ] = entry ;
33303341 }
@@ -3336,10 +3347,10 @@ static void find_deltas_for_region(struct object_entry *list UNUSED,
33363347
33373348static void find_deltas_by_region (struct object_entry * list ,
33383349 struct packing_region * regions ,
3339- uint32_t start , uint32_t nr )
3350+ size_t start , size_t nr )
33403351{
33413352 unsigned int processed = 0 ;
3342- uint32_t progress_nr ;
3353+ size_t progress_nr ;
33433354
33443355 if (!nr )
33453356 return ;
@@ -3422,7 +3433,10 @@ static void ll_find_deltas_by_region(struct object_entry *list,
34223433 }
34233434
34243435 if (progress > pack_to_stdout )
3425- fprintf_ln (stderr , _ ("Path-based delta compression using up to %d threads" ),
3436+ fprintf_ln (stderr ,
3437+ Q_ ("Path-based delta compression using up to %d thread" ,
3438+ "Path-based delta compression using up to %d threads" ,
3439+ delta_search_threads ),
34263440 delta_search_threads );
34273441 CALLOC_ARRAY (p , delta_search_threads );
34283442
@@ -4489,11 +4503,11 @@ static void mark_bitmap_preferred_tips(void)
44894503 }
44904504}
44914505
4492- static inline int is_oid_interesting (struct repository * repo ,
4493- struct object_id * oid )
4506+ static inline int is_oid_uninteresting (struct repository * repo ,
4507+ struct object_id * oid )
44944508{
44954509 struct object * o = lookup_object (repo , oid );
4496- return o && ! (o -> flags & UNINTERESTING );
4510+ return ! o || (o -> flags & UNINTERESTING );
44974511}
44984512
44994513static int add_objects_by_path (const char * path ,
@@ -4521,7 +4535,7 @@ static int add_objects_by_path(const char *path,
45214535 OBJECT_INFO_FOR_PREFETCH ) < 0 )
45224536 continue ;
45234537
4524- exclude = ! is_oid_interesting (the_repository , oid );
4538+ exclude = is_oid_uninteresting (the_repository , oid );
45254539
45264540 if (exclude && !thin )
45274541 continue ;
@@ -4553,11 +4567,11 @@ static void get_object_list_path_walk(struct rev_info *revs)
45534567{
45544568 struct path_walk_info info = PATH_WALK_INFO_INIT ;
45554569 unsigned int processed = 0 ;
4570+ int result ;
45564571
45574572 info .revs = revs ;
45584573 info .path_fn = add_objects_by_path ;
45594574 info .path_fn_data = & processed ;
4560- revs -> tag_objects = 1 ;
45614575
45624576 /*
45634577 * Allow the --[no-]sparse option to be interesting here, if only
@@ -4566,8 +4580,13 @@ static void get_object_list_path_walk(struct rev_info *revs)
45664580 * base objects.
45674581 */
45684582 info .prune_all_uninteresting = sparse ;
4583+ info .edge_aggressive = shallow ;
4584+
4585+ trace2_region_enter ("pack-objects" , "path-walk" , revs -> repo );
4586+ result = walk_objects_by_path (& info );
4587+ trace2_region_leave ("pack-objects" , "path-walk" , revs -> repo );
45694588
4570- if (walk_objects_by_path ( & info ) )
4589+ if (result )
45714590 die (_ ("failed to pack objects via path-walk" ));
45724591}
45734592
@@ -4617,7 +4636,7 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)
46174636
46184637 warn_on_object_refname_ambiguity = save_warning ;
46194638
4620- if (use_bitmap_index && !path_walk && ! get_object_list_from_bitmap (revs ))
4639+ if (use_bitmap_index && !get_object_list_from_bitmap (revs ))
46214640 return ;
46224641
46234642 if (use_delta_islands )
@@ -4767,7 +4786,6 @@ int cmd_pack_objects(int argc,
47674786 struct repository * repo UNUSED )
47684787{
47694788 int use_internal_rev_list = 0 ;
4770- int shallow = 0 ;
47714789 int all_progress_implied = 0 ;
47724790 struct strvec rp = STRVEC_INIT ;
47734791 int rev_list_unpacked = 0 , rev_list_all = 0 , rev_list_reflog = 0 ;
@@ -4947,17 +4965,18 @@ int cmd_pack_objects(int argc,
49474965
49484966 strvec_push (& rp , "pack-objects" );
49494967
4950- if (path_walk && filter_options .choice ) {
4951- warning (_ ("cannot use --filter with --path-walk" ));
4952- path_walk = 0 ;
4953- }
4954- if (path_walk && use_delta_islands ) {
4955- warning (_ ("cannot use delta islands with --path-walk" ));
4956- path_walk = 0 ;
4957- }
4958- if (path_walk && shallow ) {
4959- warning (_ ("cannot use --shallow with --path-walk" ));
4960- path_walk = 0 ;
4968+ if (path_walk ) {
4969+ const char * option = NULL ;
4970+ if (filter_options .choice )
4971+ option = "--filter" ;
4972+ else if (use_delta_islands )
4973+ option = "--delta-islands" ;
4974+
4975+ if (option ) {
4976+ warning (_ ("cannot use %s with %s" ),
4977+ option , "--path-walk" );
4978+ path_walk = 0 ;
4979+ }
49614980 }
49624981 if (path_walk ) {
49634982 strvec_push (& rp , "--boundary" );
0 commit comments