From caf3827e2f6a8a0315301d52b5bf46e269b3a388 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Tue, 21 Nov 2017 20:58:51 +0000 Subject: rev-list: add list-objects filtering support Teach rev-list to use the filtering provided by the traverse_commit_list_filtered() interface to omit unwanted objects from the result. Object filtering is only allowed when one of the "--objects*" options are used. When the "--filter-print-omitted" option is used, the omitted objects are printed at the end. These are marked with a "~". This option can be combined with "--quiet" to get a list of just the omitted objects. Add t6112 test. In the future, we will introduce a "partial clone" mechanism wherein an object in a repo, obtained from a remote, may reference a missing object that can be dynamically fetched from that remote once needed. This "partial clone" mechanism will have a way, sometimes slow, of determining if a missing link is one of the links expected to be produced by this mechanism. This patch introduces handling of missing objects to help debugging and development of the "partial clone" mechanism, and once the mechanism is implemented, for a power user to perform operations that are missing-object aware without incurring the cost of checking if a missing link is expected. Signed-off-by: Jeff Hostetler Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 4 +++- Documentation/rev-list-options.txt | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'Documentation') diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index ef22f1775..88609ff43 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -47,7 +47,9 @@ SYNOPSIS [ --fixed-strings | -F ] [ --date=] [ [ --objects | --objects-edge | --objects-edge-aggressive ] - [ --unpacked ] ] + [ --unpacked ] + [ --filter= [ --filter-print-omitted ] ] ] + [ --missing= ] [ --pretty | --header ] [ --bisect ] [ --bisect-vars ] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 13501e155..11bb87f3d 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -706,6 +706,42 @@ ifdef::git-rev-list[] --unpacked:: Only useful with `--objects`; print the object IDs that are not in packs. + +--filter=:: + Only useful with one of the `--objects*`; omits objects (usually + blobs) from the list of printed objects. The '' + may be one of the following: ++ +The form '--filter=blob:none' omits all blobs. ++ +The form '--filter=blob:limit=[kmg]' omits blobs larger than n bytes +or units. The value may be zero. ++ +The form '--filter=sparse:oid=' uses a sparse-checkout +specification contained in the object (or the object that the expression +evaluates to) to omit blobs that would not be not required for a +sparse checkout on the requested refs. ++ +The form '--filter=sparse:path=' similarly uses a sparse-checkout +specification contained in . + +--filter-print-omitted:: + Only useful with `--filter=`; prints a list of the objects omitted + by the filter. Object IDs are prefixed with a ``~'' character. + +--missing=:: + A debug option to help with future "partial clone" development. + This option specifies how missing objects are handled. ++ +The form '--missing=error' requests that rev-list stop with an error if +a missing object is encountered. This is the default action. ++ +The form '--missing=allow-any' will allow object traversal to continue +if a missing object is encountered. Missing objects will silently be +omitted from the results. ++ +The form '--missing=print' is like 'allow-any', but will also print a +list of the missing objects. Object IDs are prefixed with a ``?'' character. endif::git-rev-list[] --no-walk[=(sorted|unsorted)]:: -- cgit v1.2.1 From 9535ce7337b9add29fab3cb0021ccaf0da8c7138 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Tue, 21 Nov 2017 20:58:52 +0000 Subject: pack-objects: add list-objects filtering Teach pack-objects to use the filtering provided by the traverse_commit_list_filtered() interface to omit unwanted objects from the resulting packfile. Filtering requires the use of the "--stdout" option. Add t5317 test. In the future, we will introduce a "partial clone" mechanism wherein an object in a repo, obtained from a remote, may reference a missing object that can be dynamically fetched from that remote once needed. This "partial clone" mechanism will have a way, sometimes slow, of determining if a missing link is one of the links expected to be produced by this mechanism. This patch introduces handling of missing objects to help debugging and development of the "partial clone" mechanism, and once the mechanism is implemented, for a power user to perform operations that are missing-object aware without incurring the cost of checking if a missing link is expected. Signed-off-by: Jeff Hostetler Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- Documentation/git-pack-objects.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'Documentation') diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index 473a16135..b924c6cbf 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -12,7 +12,8 @@ SYNOPSIS 'git pack-objects' [-q | --progress | --all-progress] [--all-progress-implied] [--no-reuse-delta] [--delta-base-offset] [--non-empty] [--local] [--incremental] [--window=] [--depth=] - [--revs [--unpacked | --all]] [--stdout | base-name] + [--revs [--unpacked | --all]] + [--stdout [--filter=] | base-name] [--shallow] [--keep-true-parents] < object-list @@ -236,6 +237,22 @@ 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=:: + Requires `--stdout`. Omits certain objects (usually blobs) from + the resulting packfile. See linkgit:git-rev-list[1] for valid + `` forms. + +--missing=:: + A debug option to help with future "partial clone" development. + This option specifies how missing objects are handled. ++ +The form '--missing=error' requests that pack-objects stop with an error if +a missing object is encountered. This is the default action. ++ +The form '--missing=allow-any' will allow object traversal to continue +if a missing object is encountered. Missing objects will silently be +omitted from the results. + SEE ALSO -------- linkgit:git-rev-list[1] -- cgit v1.2.1 From 4875c9791e787af07992d3ba30061885322b7d11 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Tue, 5 Dec 2017 16:50:13 +0000 Subject: list-objects-filter-options: support --no-filter Teach opt_parse_list_objects_filter() to take --no-filter option and to free the contents of struct filter_options. This command line argument will be automatically inherited by commands using OPT_PARSE_LIST_OBJECTS_FILTER(); this includes pack-objects. Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- Documentation/git-pack-objects.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Documentation') diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index b924c6cbf..aa403d02f 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -242,6 +242,9 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle. the resulting packfile. See linkgit:git-rev-list[1] for valid `` forms. +--no-filter:: + Turns off any previous `--filter=` argument. + --missing=:: A debug option to help with future "partial clone" development. This option specifies how missing objects are handled. -- cgit v1.2.1 From f4371a883fa2d740d6b3cd436f62c9b56f13432e Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Tue, 5 Dec 2017 16:50:14 +0000 Subject: rev-list: support --no-filter argument Teach rev-list to support --no-filter to override a previous --filter= argument. This is to be consistent with commands that use OPT_PARSE macros. Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- Documentation/rev-list-options.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Documentation') diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 11bb87f3d..8d8b7f492 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -715,16 +715,21 @@ ifdef::git-rev-list[] The form '--filter=blob:none' omits all blobs. + The form '--filter=blob:limit=[kmg]' omits blobs larger than n bytes -or units. The value may be zero. +or units. n may be zero. The suffixes k, m, and g can be used to name +units in KiB, MiB, or GiB. For example, 'blob:limit=1k' is the same +as 'blob:limit=1024'. + -The form '--filter=sparse:oid=' uses a sparse-checkout -specification contained in the object (or the object that the expression -evaluates to) to omit blobs that would not be not required for a -sparse checkout on the requested refs. +The form '--filter=sparse:oid=' uses a sparse-checkout +specification contained in the blob (or blob-expression) '' +to omit blobs that would not be not required for a sparse checkout on +the requested refs. + The form '--filter=sparse:path=' similarly uses a sparse-checkout specification contained in . +--no-filter:: + Turn off any previous `--filter=` argument. + --filter-print-omitted:: Only useful with `--filter=`; prints a list of the objects omitted by the filter. Object IDs are prefixed with a ``~'' character. -- cgit v1.2.1