Merge branch 'bc/fetch-thin-less-aggressive-in-normal-repository'
authorJunio C Hamano <gitster@pobox.com>
Mon, 12 Jan 2015 19:38:56 +0000 (11:38 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Jan 2015 19:38:57 +0000 (11:38 -0800)
Earlier we made "rev-list --object-edge" more aggressively list the
objects at the edge commits, in order to reduce number of objects
fetched into a shallow repository, but the change affected cases
other than "fetching into a shallow repository" and made it
unusably slow (e.g. fetching into a normal repository should not
have to suffer the overhead from extra processing). Limit it to a
more specific case by introducing --objects-edge-aggressive, a new
option to rev-list.

* bc/fetch-thin-less-aggressive-in-normal-repository:
pack-objects: use --objects-edge-aggressive for shallow repos
rev-list: add an option to mark fewer edges as uninteresting
Documentation: add missing article in rev-list-options.txt

Documentation/git-pack-objects.txt
Documentation/git-rev-list.txt
Documentation/rev-list-options.txt
builtin/pack-objects.c
list-objects.c
revision.c
revision.h
send-pack.c
upload-pack.c
index d2d8f4792afaf5dc1105457493b070bcf163ecef..c2f76fb1ea476aa551963349ee976ad8745f10e2 100644 (file)
@@ -13,7 +13,7 @@ SYNOPSIS
        [--no-reuse-delta] [--delta-base-offset] [--non-empty]
        [--local] [--incremental] [--window=<n>] [--depth=<n>]
        [--revs [--unpacked | --all]] [--stdout | base-name]
-       [--keep-true-parents] < object-list
+       [--shallow] [--keep-true-parents] < object-list
 
 
 DESCRIPTION
@@ -190,6 +190,11 @@ required objects and is thus unusable by Git without making it
 self-contained. Use `git index-pack --fix-thin`
 (see linkgit:git-index-pack[1]) to restore the self-contained property.
 
+--shallow::
+       Optimize a pack that will be provided to a client with a shallow
+       repository.  This option, combined with \--thin, can result in a
+       smaller pack at the cost of speed.
+
 --delta-base-offset::
        A packed archive can express the base object of a delta as
        either a 20-byte object name or as an offset in the
index fd7f8b5bc1840bc93273dd7b076d86499626912a..5b119220bf168153d63bf2051a065e40b68c1ed3 100644 (file)
@@ -46,7 +46,8 @@ SYNOPSIS
             [ \--extended-regexp | -E ]
             [ \--fixed-strings | -F ]
             [ \--date=(local|relative|default|iso|iso-strict|rfc|short) ]
-            [ [\--objects | \--objects-edge] [ \--unpacked ] ]
+            [ [ \--objects | \--objects-edge | \--objects-edge-aggressive ]
+              [ \--unpacked ] ]
             [ \--pretty | \--header ]
             [ \--bisect ]
             [ \--bisect-vars ]
index afccfdc23a38f2dca84ebeff2cc8624eb8a0e23e..2984f407a9f3084235fd0207a82ea44a424942ed 100644 (file)
@@ -653,10 +653,15 @@ These options are mostly targeted for packing of Git repositories.
 --objects-edge::
        Similar to `--objects`, but also print the IDs of excluded
        commits prefixed with a ``-'' character.  This is used by
-       linkgit:git-pack-objects[1] to build ``thin'' pack, which records
+       linkgit:git-pack-objects[1] to build ``thin'' pack, which records
        objects in deltified form based on objects contained in these
        excluded commits to reduce network traffic.
 
+--objects-edge-aggressive::
+       Similar to `--objects-edge`, but it tries harder to find excluded
+       commits at the cost of increased time.  This is used instead of
+       `--objects-edge` to build ``thin'' packs for shallow repositories.
+
 --unpacked::
        Only useful with `--objects`; print the object IDs that are not
        in packs.
index 3f9f5c7760a63bc2deb32b75f500ac0d1bc87538..d8165878e1d466e49719038b1badc524d5627270 100644 (file)
@@ -2613,6 +2613,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 {
        int use_internal_rev_list = 0;
        int thin = 0;
+       int shallow = 0;
        int all_progress_implied = 0;
        struct argv_array rp = ARGV_ARRAY_INIT;
        int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
@@ -2677,6 +2678,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                  PARSE_OPT_OPTARG, option_parse_unpack_unreachable },
                OPT_BOOL(0, "thin", &thin,
                         N_("create thin packs")),
+               OPT_BOOL(0, "shallow", &shallow,
+                        N_("create packs suitable for shallow fetches")),
                OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep,
                         N_("ignore packs that have companion .keep file")),
                OPT_INTEGER(0, "compression", &pack_compression_level,
@@ -2711,7 +2714,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
        argv_array_push(&rp, "pack-objects");
        if (thin) {
                use_internal_rev_list = 1;
-               argv_array_push(&rp, "--objects-edge");
+               argv_array_push(&rp, shallow
+                               ? "--objects-edge-aggressive"
+                               : "--objects-edge");
        } else
                argv_array_push(&rp, "--objects");
 
index 2910becd6c65b66670215aefdf08e1933895aa39..2a139b6ced68809f3a324f493325ec62c3a44044 100644 (file)
@@ -157,7 +157,7 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
 
                if (commit->object.flags & UNINTERESTING) {
                        mark_tree_uninteresting(commit->tree);
-                       if (revs->edge_hint && !(commit->object.flags & SHOWN)) {
+                       if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
                                commit->object.flags |= SHOWN;
                                show_edge(commit);
                        }
@@ -165,7 +165,7 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
                }
                mark_edge_parents_uninteresting(commit, revs, show_edge);
        }
-       if (revs->edge_hint) {
+       if (revs->edge_hint_aggressive) {
                for (i = 0; i < revs->cmdline.nr; i++) {
                        struct object *obj = revs->cmdline.rev[i].item;
                        struct commit *commit = (struct commit *)obj;
index 14e0e0358cf19dc95a5509ec441335a70a277503..86406a26a2d4599ea401d1faa9a817cadb3b7bcd 100644 (file)
@@ -1853,6 +1853,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
                revs->tree_objects = 1;
                revs->blob_objects = 1;
                revs->edge_hint = 1;
+       } else if (!strcmp(arg, "--objects-edge-aggressive")) {
+               revs->tag_objects = 1;
+               revs->tree_objects = 1;
+               revs->blob_objects = 1;
+               revs->edge_hint = 1;
+               revs->edge_hint_aggressive = 1;
        } else if (!strcmp(arg, "--verify-objects")) {
                revs->tag_objects = 1;
                revs->tree_objects = 1;
index 9cb5adc4ea25bfdc37ced8b8a98b1fd58661c9e9..033a24460e71b723f95ef91f4b6f0dbfd8c2c390 100644 (file)
@@ -93,6 +93,7 @@ struct rev_info {
                        blob_objects:1,
                        verify_objects:1,
                        edge_hint:1,
+                       edge_hint_aggressive:1,
                        limited:1,
                        unpacked:1,
                        boundary:2,
index 949cb61aa0d681e30b7e8199ef9e31ff0caee089..25947d7df9dd3af6e665d5d5eb63ec970617aef1 100644 (file)
@@ -47,6 +47,7 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
                NULL,
                NULL,
                NULL,
+               NULL,
        };
        struct child_process po = CHILD_PROCESS_INIT;
        int i;
@@ -60,6 +61,8 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru
                argv[i++] = "-q";
        if (args->progress)
                argv[i++] = "--progress";
+       if (is_repository_shallow())
+               argv[i++] = "--shallow";
        po.argv = argv;
        po.in = -1;
        po.out = args->stateless_rpc ? -1 : fd;
index ac9ac1592d818da5ae90ec065581e3bf218ffc39..b531a325d2864e94bdc86e689f78663255bb7cf2 100644 (file)
@@ -86,7 +86,7 @@ static void create_pack_file(void)
                "corruption on the remote side.";
        int buffered = -1;
        ssize_t sz;
-       const char *argv[12];
+       const char *argv[13];
        int i, arg = 0;
        FILE *pipe_fd;
 
@@ -100,6 +100,8 @@ static void create_pack_file(void)
                argv[arg++] = "--thin";
 
        argv[arg++] = "--stdout";
+       if (shallow_nr)
+               argv[arg++] = "--shallow";
        if (!no_progress)
                argv[arg++] = "--progress";
        if (use_ofs_delta)