Skip to content

Commit a85c9c1

Browse files
committed
fixup! pack-objects: add --path-walk option
Signed-off-by: Derrick Stolee <[email protected]>
1 parent 35a2f21 commit a85c9c1

File tree

4 files changed

+10
-167
lines changed

4 files changed

+10
-167
lines changed

Documentation/git-pack-objects.adoc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SYNOPSIS
1616
[--cruft] [--cruft-expiration=<time>]
1717
[--stdout [--filter=<filter-spec>] | <base-name>]
1818
[--shallow] [--keep-true-parents] [--[no-]sparse]
19-
[--name-hash-version=<n>] [--path-walk] < <object-list>
19+
[--name-hash-version=<n>] < <object-list>
2020

2121

2222
DESCRIPTION
@@ -375,16 +375,6 @@ many different directories. At the moment, this version is not allowed
375375
when writing reachability bitmap files with `--write-bitmap-index` and it
376376
will be automatically changed to version `1`.
377377
378-
--path-walk::
379-
By default, `git pack-objects` walks objects in an order that
380-
presents trees and blobs in an order unrelated to the path they
381-
appear relative to a commit's root tree. The `--path-walk` option
382-
enables a different walking algorithm that organizes trees and
383-
blobs by path. This has the potential to improve delta compression
384-
especially in the presence of filenames that cause collisions in
385-
Git's default name-hash algorithm. Due to changing how the objects
386-
are walked, this option is not compatible with `--delta-islands`,
387-
`--shallow`, or `--filter`.
388378
389379
DELTA ISLANDS
390380
-------------

Documentation/technical/api-path-walk.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,3 @@ Examples
7070
See example usages in:
7171
`t/helper/test-path-walk.c`,
7272
`builtin/backfill.c`
73-
`builtin/pack-objects.c`

builtin/pack-objects.c

Lines changed: 9 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
#include "promisor-remote.h"
4242
#include "pack-mtimes.h"
4343
#include "parse-options.h"
44-
#include "blob.h"
45-
#include "tree.h"
46-
#include "path-walk.h"
4744

4845
/*
4946
* Objects we are going to pack are collected in the `to_pack` structure.
@@ -221,7 +218,6 @@ static int delta_search_threads;
221218
static int pack_to_stdout;
222219
static int sparse;
223220
static int thin;
224-
static int path_walk;
225221
static int num_preferred_base;
226222
static struct progress *progress_state;
227223

@@ -4281,105 +4277,6 @@ static void mark_bitmap_preferred_tips(void)
42814277
}
42824278
}
42834279

4284-
static inline int is_oid_interesting(struct repository *repo,
4285-
struct object_id *oid)
4286-
{
4287-
struct object *o = lookup_object(repo, oid);
4288-
return o && !(o->flags & UNINTERESTING);
4289-
}
4290-
4291-
static int add_objects_by_path(const char *path,
4292-
struct oid_array *oids,
4293-
enum object_type type,
4294-
void *data)
4295-
{
4296-
struct object_entry **delta_list;
4297-
size_t oe_start = to_pack.nr_objects;
4298-
size_t oe_end;
4299-
unsigned int sub_list_size;
4300-
unsigned int *processed = data;
4301-
4302-
/*
4303-
* First, add all objects to the packing data, including the ones
4304-
* marked UNINTERESTING (translated to 'exclude') as they can be
4305-
* used as delta bases.
4306-
*/
4307-
for (size_t i = 0; i < oids->nr; i++) {
4308-
int exclude;
4309-
struct object_info oi = OBJECT_INFO_INIT;
4310-
struct object_id *oid = &oids->oid[i];
4311-
4312-
/* Skip objects that do not exist locally. */
4313-
if (exclude_promisor_objects &&
4314-
oid_object_info_extended(the_repository, oid, &oi,
4315-
OBJECT_INFO_FOR_PREFETCH) < 0)
4316-
continue;
4317-
4318-
exclude = !is_oid_interesting(the_repository, oid);
4319-
4320-
if (exclude && !thin)
4321-
continue;
4322-
4323-
add_object_entry(oid, type, path, exclude);
4324-
}
4325-
4326-
oe_end = to_pack.nr_objects;
4327-
4328-
/* We can skip delta calculations if it is a no-op. */
4329-
if (oe_end == oe_start || !window)
4330-
return 0;
4331-
4332-
sub_list_size = 0;
4333-
ALLOC_ARRAY(delta_list, oe_end - oe_start);
4334-
4335-
for (size_t i = 0; i < oe_end - oe_start; i++) {
4336-
struct object_entry *entry = to_pack.objects + oe_start + i;
4337-
4338-
if (!should_attempt_deltas(entry))
4339-
continue;
4340-
4341-
delta_list[sub_list_size++] = entry;
4342-
}
4343-
4344-
/*
4345-
* Find delta bases among this list of objects that all match the same
4346-
* path. This causes the delta compression to be interleaved in the
4347-
* object walk, which can lead to confusing progress indicators. This is
4348-
* also incompatible with threaded delta calculations. In the future,
4349-
* consider creating a list of regions in the full to_pack.objects array
4350-
* that could be picked up by the threaded delta computation.
4351-
*/
4352-
if (sub_list_size && window) {
4353-
QSORT(delta_list, sub_list_size, type_size_sort);
4354-
find_deltas(delta_list, &sub_list_size, window, depth, processed);
4355-
}
4356-
4357-
free(delta_list);
4358-
return 0;
4359-
}
4360-
4361-
static void get_object_list_path_walk(struct rev_info *revs)
4362-
{
4363-
struct path_walk_info info = PATH_WALK_INFO_INIT;
4364-
unsigned int processed = 0;
4365-
4366-
info.revs = revs;
4367-
info.path_fn = add_objects_by_path;
4368-
info.path_fn_data = &processed;
4369-
revs->tag_objects = 1;
4370-
4371-
/*
4372-
* Allow the --[no-]sparse option to be interesting here, if only
4373-
* for testing purposes. Paths with no interesting objects will not
4374-
* contribute to the resulting pack, but only create noisy preferred
4375-
* base objects.
4376-
*/
4377-
info.prune_all_uninteresting = sparse;
4378-
4379-
if (walk_objects_by_path(&info))
4380-
die(_("failed to pack objects via path-walk"));
4381-
}
4382-
43834280
static void get_object_list(struct rev_info *revs, int ac, const char **av)
43844281
{
43854282
struct setup_revision_opt s_r_opt = {
@@ -4426,7 +4323,7 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)
44264323

44274324
warn_on_object_refname_ambiguity = save_warning;
44284325

4429-
if (use_bitmap_index && !path_walk && !get_object_list_from_bitmap(revs))
4326+
if (use_bitmap_index && !get_object_list_from_bitmap(revs))
44304327
return;
44314328

44324329
if (use_delta_islands)
@@ -4435,19 +4332,15 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)
44354332
if (write_bitmap_index)
44364333
mark_bitmap_preferred_tips();
44374334

4335+
if (prepare_revision_walk(revs))
4336+
die(_("revision walk setup failed"));
4337+
mark_edges_uninteresting(revs, show_edge, sparse);
4338+
44384339
if (!fn_show_object)
44394340
fn_show_object = show_object;
4440-
4441-
if (path_walk) {
4442-
get_object_list_path_walk(revs);
4443-
} else {
4444-
if (prepare_revision_walk(revs))
4445-
die(_("revision walk setup failed"));
4446-
mark_edges_uninteresting(revs, show_edge, sparse);
4447-
traverse_commit_list(revs,
4448-
show_commit, fn_show_object,
4449-
NULL);
4450-
}
4341+
traverse_commit_list(revs,
4342+
show_commit, fn_show_object,
4343+
NULL);
44514344

44524345
if (unpack_unreachable_expiration) {
44534346
revs->ignore_missing_links = 1;
@@ -4657,8 +4550,6 @@ int cmd_pack_objects(int argc,
46574550
N_("use the sparse reachability algorithm")),
46584551
OPT_BOOL(0, "thin", &thin,
46594552
N_("create thin packs")),
4660-
OPT_BOOL(0, "path-walk", &path_walk,
4661-
N_("use the path-walk API to walk objects when possible")),
46624553
OPT_BOOL(0, "shallow", &shallow,
46634554
N_("create packs suitable for shallow fetches")),
46644555
OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep_on_disk,
@@ -4744,27 +4635,7 @@ int cmd_pack_objects(int argc,
47444635
window = 0;
47454636

47464637
strvec_push(&rp, "pack-objects");
4747-
4748-
if (path_walk && filter_options.choice) {
4749-
warning(_("cannot use --filter with --path-walk"));
4750-
path_walk = 0;
4751-
}
4752-
if (path_walk && use_delta_islands) {
4753-
warning(_("cannot use delta islands with --path-walk"));
4754-
path_walk = 0;
4755-
}
4756-
if (path_walk && shallow) {
4757-
warning(_("cannot use --shallow with --path-walk"));
4758-
path_walk = 0;
4759-
}
4760-
if (path_walk) {
4761-
strvec_push(&rp, "--boundary");
4762-
/*
4763-
* We must disable the bitmaps because we are removing
4764-
* the --objects / --objects-edge[-aggressive] options.
4765-
*/
4766-
use_bitmap_index = 0;
4767-
} else if (thin) {
4638+
if (thin) {
47684639
use_internal_rev_list = 1;
47694640
strvec_push(&rp, shallow
47704641
? "--objects-edge-aggressive"

t/t5300-pack-object.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -723,21 +723,4 @@ test_expect_success '--name-hash-version=2 and --write-bitmap-index are incompat
723723
! test_grep "currently, --write-bitmap-index requires --name-hash-version=1" err
724724
'
725725

726-
# Basic "repack everything" test
727-
test_expect_success '--path-walk pack everything' '
728-
git -C server rev-parse HEAD >in &&
729-
git -C server pack-objects --stdout --revs --path-walk <in >out.pack &&
730-
git -C server index-pack --stdin <out.pack
731-
'
732-
733-
# Basic "thin pack" test
734-
test_expect_success '--path-walk thin pack' '
735-
cat >in <<-EOF &&
736-
$(git -C server rev-parse HEAD)
737-
^$(git -C server rev-parse HEAD~2)
738-
EOF
739-
git -C server pack-objects --thin --stdout --revs --path-walk <in >out.pack &&
740-
git -C server index-pack --fix-thin --stdin <out.pack
741-
'
742-
743726
test_done

0 commit comments

Comments
 (0)