44
44
#include "blob.h"
45
45
#include "tree.h"
46
46
#include "path-walk.h"
47
+ #include "trace2.h"
47
48
48
49
/*
49
50
* 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,
187
188
#define SET_DELTA_SIBLING (obj , val ) oe_set_delta_sibling(&to_pack, obj, val)
188
189
189
190
static 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>" ),
192
199
NULL
193
200
};
194
201
@@ -203,6 +210,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
203
210
static timestamp_t unpack_unreachable_expiration ;
204
211
static int pack_loose_unreachable ;
205
212
static int cruft ;
213
+ static int shallow = 0 ;
206
214
static timestamp_t cruft_expiration ;
207
215
static int local ;
208
216
static int have_non_local_packs ;
@@ -3291,6 +3299,9 @@ static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, cons
3291
3299
static int should_attempt_deltas (struct object_entry * entry )
3292
3300
{
3293
3301
if (DELTA (entry ))
3302
+ /* This happens if we decided to reuse existing
3303
+ * delta from a pack. "reuse_delta &&" is implied.
3304
+ */
3294
3305
return 0 ;
3295
3306
3296
3307
if (!entry -> type_valid ||
@@ -3315,16 +3326,16 @@ static int should_attempt_deltas(struct object_entry *entry)
3315
3326
return 1 ;
3316
3327
}
3317
3328
3318
- static void find_deltas_for_region (struct object_entry * list UNUSED ,
3329
+ static void find_deltas_for_region (struct object_entry * list ,
3319
3330
struct packing_region * region ,
3320
3331
unsigned int * processed )
3321
3332
{
3322
3333
struct object_entry * * delta_list ;
3323
- uint32_t delta_list_nr = 0 ;
3334
+ unsigned int delta_list_nr = 0 ;
3324
3335
3325
3336
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 ;
3328
3339
if (should_attempt_deltas (entry ))
3329
3340
delta_list [delta_list_nr ++ ] = entry ;
3330
3341
}
@@ -3336,10 +3347,10 @@ static void find_deltas_for_region(struct object_entry *list UNUSED,
3336
3347
3337
3348
static void find_deltas_by_region (struct object_entry * list ,
3338
3349
struct packing_region * regions ,
3339
- uint32_t start , uint32_t nr )
3350
+ size_t start , size_t nr )
3340
3351
{
3341
3352
unsigned int processed = 0 ;
3342
- uint32_t progress_nr ;
3353
+ size_t progress_nr ;
3343
3354
3344
3355
if (!nr )
3345
3356
return ;
@@ -3422,7 +3433,10 @@ static void ll_find_deltas_by_region(struct object_entry *list,
3422
3433
}
3423
3434
3424
3435
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 ),
3426
3440
delta_search_threads );
3427
3441
CALLOC_ARRAY (p , delta_search_threads );
3428
3442
@@ -4489,11 +4503,11 @@ static void mark_bitmap_preferred_tips(void)
4489
4503
}
4490
4504
}
4491
4505
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 )
4494
4508
{
4495
4509
struct object * o = lookup_object (repo , oid );
4496
- return o && ! (o -> flags & UNINTERESTING );
4510
+ return ! o || (o -> flags & UNINTERESTING );
4497
4511
}
4498
4512
4499
4513
static int add_objects_by_path (const char * path ,
@@ -4521,7 +4535,7 @@ static int add_objects_by_path(const char *path,
4521
4535
OBJECT_INFO_FOR_PREFETCH ) < 0 )
4522
4536
continue ;
4523
4537
4524
- exclude = ! is_oid_interesting (the_repository , oid );
4538
+ exclude = is_oid_uninteresting (the_repository , oid );
4525
4539
4526
4540
if (exclude && !thin )
4527
4541
continue ;
@@ -4553,11 +4567,11 @@ static void get_object_list_path_walk(struct rev_info *revs)
4553
4567
{
4554
4568
struct path_walk_info info = PATH_WALK_INFO_INIT ;
4555
4569
unsigned int processed = 0 ;
4570
+ int result ;
4556
4571
4557
4572
info .revs = revs ;
4558
4573
info .path_fn = add_objects_by_path ;
4559
4574
info .path_fn_data = & processed ;
4560
- revs -> tag_objects = 1 ;
4561
4575
4562
4576
/*
4563
4577
* 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)
4566
4580
* base objects.
4567
4581
*/
4568
4582
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 );
4569
4588
4570
- if (walk_objects_by_path ( & info ) )
4589
+ if (result )
4571
4590
die (_ ("failed to pack objects via path-walk" ));
4572
4591
}
4573
4592
@@ -4617,7 +4636,7 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)
4617
4636
4618
4637
warn_on_object_refname_ambiguity = save_warning ;
4619
4638
4620
- if (use_bitmap_index && !path_walk && ! get_object_list_from_bitmap (revs ))
4639
+ if (use_bitmap_index && !get_object_list_from_bitmap (revs ))
4621
4640
return ;
4622
4641
4623
4642
if (use_delta_islands )
@@ -4767,7 +4786,6 @@ int cmd_pack_objects(int argc,
4767
4786
struct repository * repo UNUSED )
4768
4787
{
4769
4788
int use_internal_rev_list = 0 ;
4770
- int shallow = 0 ;
4771
4789
int all_progress_implied = 0 ;
4772
4790
struct strvec rp = STRVEC_INIT ;
4773
4791
int rev_list_unpacked = 0 , rev_list_all = 0 , rev_list_reflog = 0 ;
@@ -4947,17 +4965,18 @@ int cmd_pack_objects(int argc,
4947
4965
4948
4966
strvec_push (& rp , "pack-objects" );
4949
4967
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
+ }
4961
4980
}
4962
4981
if (path_walk ) {
4963
4982
strvec_push (& rp , "--boundary" );
0 commit comments