Skip to content

WIP v0 partial merge #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c91c92d
dir: refactor add_excludes()
jeffhostetler Jun 29, 2017
2b621d6
oidset2: create oidset subclass with object length and pathname
jeffhostetler Jun 26, 2017
82f7390
list-objects: filter objects in traverse_commit_list
jeffhostetler Jun 30, 2017
80481e6
list-objects-filter-blobs-none: add filter to omit all blobs
jeffhostetler Sep 1, 2017
48a9413
list-objects-filter-blobs-limit: add large blob filtering
jeffhostetler Sep 1, 2017
ac37825
list-objects-filter-sparse: add sparse filter
jeffhostetler Sep 1, 2017
5b0696a
list-objects-filter-options: common argument parsing
jeffhostetler Jul 6, 2017
d8dfa44
list-objects: add traverse_commit_list_filtered method
jeffhostetler Sep 1, 2017
58f747e
rev-list: add list-objects filtering support
jeffhostetler Jun 30, 2017
a3b9729
rev-list: document list-objects filtering
jeffhostetler Jun 30, 2017
03fb7bf
t6112: rev-list object filtering test
jeffhostetler Jun 30, 2017
624e5a2
pack-objects: add list-objects filtering
jeffhostetler Sep 7, 2017
a899dc3
pack-objects: document list-objects filtering
jeffhostetler Sep 7, 2017
8d05df8
pack-protocol: document list-objects filtering
jeffhostetler Sep 7, 2017
64e1eb4
upload-pack: add list-objects filtering
jeffhostetler Sep 7, 2017
0cd2a31
transport: add list-objects filtering
jeffhostetler Sep 7, 2017
f55d785
fetch-pack: add list-objects filtering
jeffhostetler Sep 7, 2017
9c2a2ac
REMOVE: connected: add filter-relax
jeffhostetler Sep 7, 2017
74555d3
REMOVE: index-pack: add filter-relax
jeffhostetler Sep 7, 2017
4446072
clone: add list-objects filtering
jeffhostetler Sep 7, 2017
4ab5a0b
fetch: add list-objects filtering parameters
jeffhostetler Sep 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Documentation/git-pack-objects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
With this option, parents that are hidden by grafts are packed
nevertheless.

--filter-omit-all-blobs::
Requires `--stdout`. Omits all blobs from the packfile.

--filter-omit-large-blobs=<n>[kmg]::
Requires `--stdout`. Omits large blobs larger than n bytes from
the packfile. May optionally be followed by 'k', 'm', or 'g' units.
Value may be zero. Special files (matching ".git*") are always
included, regardless of size.

--filter-use-blob=<blob-ish>::
--filter-use-path=<path>::
Requires `--stdout`. Use a sparse-checkout specification to
filter the resulting packfile to only contain the blobs that
would be referenced by such a sparse-checkout. `<path>` specifies
a local pathname. `<blob-ish>` specifies an expression that can
be evaluated to a blob.

SEE ALSO
--------
linkgit:git-rev-list[1]
Expand Down
9 changes: 8 additions & 1 deletion Documentation/git-rev-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ SYNOPSIS
[ --fixed-strings | -F ]
[ --date=<format>]
[ [ --objects | --objects-edge | --objects-edge-aggressive ]
[ --unpacked ] ]
[ --unpacked ]
[ [ --filter-omit-all-blobs |
--filter-omit-large-blobs=<n>[kmg] |
--filter-use-blob=<blob-ish> |
--filter-use-path=<path> ]
[ --filter-print-missing ]
[ --filter-print-omitted ] ] ]
[ --filter-relax ]
[ --pretty | --header ]
[ --bisect ]
[ --bisect-vars ]
Expand Down
32 changes: 32 additions & 0 deletions Documentation/rev-list-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,38 @@ ifdef::git-rev-list[]
--unpacked::
Only useful with `--objects`; print the object IDs that are not
in packs.

--filter-omit-all-blobs::
Only useful with one of the `--objects*`; omits all blobs from
the printed list of objects.

--filter-omit-large-blobs=<n>[kmg]::
Only useful with one of the `--objects*`; omits blobs larger than
n bytes from the printed list of objects. May optionally be
followed by 'k', 'm', or 'g' units. Value may be zero. Special
files (matching ".git*") are always included, regardless of size.

--filter-use-blob=<blob-ish>::
--filter-use-path=<path>::
Only useful with one of the `--objects*`; uses a sparse-checkout
specification contained in the given object or file to filter the
result to only contain blobs referenced by such a sparse-checkout.

--filter-print-missing::
Prints a list of the missing objects for the requested traversal.
Object IDs are prefixed with a ``?'' character. The object type
is printed after the ID. This may be used with or without any of
the above filtering options.

--filter-print-omitted::
Only useful with one of the above `--filter*`; prints a list
of the omitted objects. Object IDs are prefixed with a ``~''
character. The object size is printed after the ID.

--filter-relax::
Relax consistency checking for missing blobs. Do not warn of
missing blobs during normal (non-filtering) object traversal
following an earlier partial/narrow clone or fetch.
endif::git-rev-list[]

--no-walk[=(sorted|unsorted)]::
Expand Down
19 changes: 19 additions & 0 deletions Documentation/technical/pack-protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ out of what the server said it could do with the first 'want' line.
upload-request = want-list
*shallow-line
*1depth-request
[filter-request]
flush-pkt

want-list = first-want
Expand All @@ -227,6 +228,13 @@ out of what the server said it could do with the first 'want' line.
additional-want = PKT-LINE("want" SP obj-id)

depth = 1*DIGIT

filter-request = PKT-LINE("filter-omit-all-blobs") /
PKT-LINE("filter-omit-large-blobs" SP magnitude) /
PKT-LINE("filter-use-blob" SP obj-id)
PKT-LINE("filter-use-path" SP path)

magnitude = 1*DIGIT [ "k" | "m" | "g" ]
----

Clients MUST send all the obj-ids it wants from the reference
Expand All @@ -249,6 +257,17 @@ complete those commits. Commits whose parents are not received as a
result are defined as shallow and marked as such in the server. This
information is sent back to the client in the next step.

The client can optionally request that pack-objects omit various
objects from the packfile using one of several filtering techniques.
These are intended for use with partial clone/fetch operations.
"filter-omit-all-blobs" requests that all blobs be omitted from the
packfile. "filter-omit-large-blobs" requests that blobs larger than
the requested size be omitted, unless they have a ".git*" special
filename. "filter-use-blob" requests blob filtering based upon a
sparse-checkout specification in the named blob. "filter-use-path"
request blob filtering based upon a sparse-checkout specification
file.

Once all the 'want's and 'shallow's (and optional 'deepen') are
transferred, clients MUST send a flush-pkt, to tell the server side
that it is done sending the list.
Expand Down
7 changes: 7 additions & 0 deletions Documentation/technical/protocol-capabilities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,10 @@ to accept a signed push certificate, and asks the <nonce> to be
included in the push certificate. A send-pack client MUST NOT
send a push-cert packet unless the receive-pack server advertises
this capability.

filter-objects
--------------

If the upload-pack server advertises the 'filter-objects' capability,
fetch-pack may send "filter-*" commands to request a partial clone
or fetch where the server omits various objects from the packfile.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ LIB_OBJS += levenshtein.o
LIB_OBJS += line-log.o
LIB_OBJS += line-range.o
LIB_OBJS += list-objects.o
LIB_OBJS += list-objects-filter-blobs-none.o
LIB_OBJS += list-objects-filter-blobs-limit.o
LIB_OBJS += list-objects-filter-options.o
LIB_OBJS += list-objects-filter-sparse.o
LIB_OBJS += ll-merge.o
LIB_OBJS += lockfile.o
LIB_OBJS += log-tree.o
Expand All @@ -822,6 +826,7 @@ LIB_OBJS += notes-merge.o
LIB_OBJS += notes-utils.o
LIB_OBJS += object.o
LIB_OBJS += oidset.o
LIB_OBJS += oidset2.o
LIB_OBJS += packfile.o
LIB_OBJS += pack-bitmap.o
LIB_OBJS += pack-bitmap-write.o
Expand Down
11 changes: 11 additions & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "run-command.h"
#include "connected.h"
#include "packfile.h"
#include "list-objects-filter-options.h"

/*
* Overall FIXMEs:
Expand Down Expand Up @@ -60,6 +61,7 @@ static struct string_list option_optional_reference = STRING_LIST_INIT_NODUP;
static int option_dissociate;
static int max_jobs = -1;
static struct string_list option_recurse_submodules = STRING_LIST_INIT_NODUP;
static struct list_objects_filter_options filter_options;

static int recurse_submodules_cb(const struct option *opt,
const char *arg, int unset)
Expand Down Expand Up @@ -135,6 +137,7 @@ static struct option builtin_clone_options[] = {
TRANSPORT_FAMILY_IPV4),
OPT_SET_INT('6', "ipv6", &family, N_("use IPv6 addresses only"),
TRANSPORT_FAMILY_IPV6),
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
OPT_END()
};

Expand Down Expand Up @@ -648,6 +651,8 @@ static void update_remote_refs(const struct ref *refs,
if (check_connectivity) {
struct check_connected_options opt = CHECK_CONNECTED_INIT;

opt.filter_relax = filter_options.choice != LOFC_DISABLED;

opt.transport = transport;
opt.progress = transport->progress;

Expand Down Expand Up @@ -1073,6 +1078,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
warning(_("--shallow-since is ignored in local clones; use file:// instead."));
if (option_not.nr)
warning(_("--shallow-exclude is ignored in local clones; use file:// instead."));
if (filter_options.choice)
warning(_("Object filtering is ignored in local clones; use file:// instead."));
if (!access(mkpath("%s/shallow", path), F_OK)) {
if (option_local > 0)
warning(_("source repository is shallow, ignoring --local"));
Expand Down Expand Up @@ -1104,6 +1111,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
option_upload_pack);

if (filter_options.choice)
transport_set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER,
filter_options.raw_value);

if (transport->smart_options && !deepen)
transport->smart_options->check_self_contained_and_connected = 1;

Expand Down
5 changes: 5 additions & 0 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
args.update_shallow = 1;
continue;
}
if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
parse_list_objects_filter(&args.filter_options, arg);
continue;
}

usage(fetch_pack_usage);
}
if (deepen_not.nr)
Expand Down
10 changes: 9 additions & 1 deletion builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "argv-array.h"
#include "utf8.h"
#include "packfile.h"
#include "list-objects-filter-options.h"

static const char * const builtin_fetch_usage[] = {
N_("git fetch [<options>] [<repository> [<refspec>...]]"),
Expand Down Expand Up @@ -55,6 +56,7 @@ static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND;
static int shown_url = 0;
static int refmap_alloc, refmap_nr;
static const char **refmap_array;
static struct list_objects_filter_options filter_options;

static int git_fetch_config(const char *k, const char *v, void *cb)
{
Expand Down Expand Up @@ -160,6 +162,7 @@ static struct option builtin_fetch_options[] = {
TRANSPORT_FAMILY_IPV4),
OPT_SET_INT('6', "ipv6", &family, N_("use IPv6 addresses only"),
TRANSPORT_FAMILY_IPV6),
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
OPT_END()
};

Expand Down Expand Up @@ -754,6 +757,9 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
int want_status;
int summary_width = transport_summary_width(ref_map);
struct check_connected_options opt = CHECK_CONNECTED_INIT;

opt.filter_relax = filter_options.choice != LOFC_DISABLED;

fp = fopen(filename, "a");
if (!fp)
Expand All @@ -765,7 +771,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
url = xstrdup("foreign");

rm = ref_map;
if (check_connected(iterate_ref_map, &rm, NULL)) {
if (check_connected(iterate_ref_map, &rm, &opt)) {
rc = error(_("%s did not send all necessary objects\n"), url);
goto abort;
}
Expand Down Expand Up @@ -906,6 +912,8 @@ static int quickfetch(struct ref *ref_map)
struct ref *rm = ref_map;
struct check_connected_options opt = CHECK_CONNECTED_INIT;

opt.filter_relax = filter_options.choice != LOFC_DISABLED;

/*
* If we are deepening a shallow clone we already have these
* objects reachable. Running rev-list here will return with
Expand Down
15 changes: 15 additions & 0 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "streaming.h"
#include "thread-utils.h"
#include "packfile.h"
#include "list-objects-filter-options.h"

static const char index_pack_usage[] =
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
Expand Down Expand Up @@ -82,6 +83,7 @@ static int verbose;
static int show_resolving_progress;
static int show_stat;
static int check_self_contained_and_connected;
static int filter_relax;

static struct progress *progress;

Expand Down Expand Up @@ -222,6 +224,17 @@ static unsigned check_object(struct object *obj)
if (!(obj->flags & FLAG_CHECKED)) {
unsigned long size;
int type = sha1_object_info(obj->oid.hash, &size);

if (type <= 0 && filter_relax) {
/*
* Relax consistency checks to not complain about
* missing objects (presumably because of earlier
* object filtering).
*/
obj->flags |= FLAG_CHECKED;
return 0;
}

if (type <= 0)
die(_("did not receive expected object %s"),
oid_to_hex(&obj->oid));
Expand Down Expand Up @@ -1728,6 +1741,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
die(_("bad %s"), arg);
} else if (skip_prefix(arg, "--max-input-size=", &arg)) {
max_input_size = strtoumax(arg, NULL, 10);
} else if (!strcmp(arg, "--filter-relax")) {
filter_relax = 1;
} else
usage(index_pack_usage);
continue;
Expand Down
18 changes: 17 additions & 1 deletion builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ static unsigned long cache_max_small_delta_size = 1000;

static unsigned long window_memory_limit = 0;

static struct list_objects_filter_options filter_options;

/*
* stats
*/
Expand Down Expand Up @@ -2816,7 +2818,12 @@ static void get_object_list(int ac, const char **av)
if (prepare_revision_walk(&revs))
die("revision walk setup failed");
mark_edges_uninteresting(&revs, show_edge);
traverse_commit_list(&revs, show_commit, show_object, NULL);
if (filter_options.choice)
traverse_commit_list_filtered(&filter_options, &revs,
show_commit, show_object,
NULL, NULL);
else
traverse_commit_list(&revs, show_commit, show_object, NULL);

if (unpack_unreachable_expiration) {
revs.ignore_missing_links = 1;
Expand Down Expand Up @@ -2952,6 +2959,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
N_("use a bitmap index if available to speed up counting objects")),
OPT_BOOL(0, "write-bitmap-index", &write_bitmap_index,
N_("write a bitmap index together with the pack index")),

OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),

OPT_END(),
};

Expand Down Expand Up @@ -3028,6 +3038,12 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
unpack_unreachable_expiration = 0;

if (filter_options.choice) {
if (!pack_to_stdout)
die("cannot use filtering with an indexable pack.");
use_bitmap_index = 0;
}

/*
* "soft" reasons not to use bitmaps - for on-disk repack by default we want
*
Expand Down
Loading