]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/fetch-pack: add --refetch option
authorRobert Coup <robert@coup.net.nz>
Mon, 28 Mar 2022 14:02:07 +0000 (14:02 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Mar 2022 17:25:52 +0000 (10:25 -0700)
Add a refetch option to fetch-pack to force a full fetch. Use when
applying a new partial clone filter to refetch all matching objects.

Signed-off-by: Robert Coup <robert@coup.net.nz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-fetch-pack.txt
builtin/fetch-pack.c
remote-curl.c

index c9758847937e7db9fb3c4c3a498f5074e9e1f5d9..46747d5f429164f817444cd502d8bff4dc5cbe4d 100644 (file)
@@ -101,6 +101,10 @@ be in a separate packet, and the list must end with a flush packet.
        current shallow boundary instead of from the tip of each
        remote branch history.
 
+--refetch::
+       Skips negotiating commits with the server in order to fetch all matching
+       objects. Use to reapply a new partial clone blob/tree filter.
+
 --no-progress::
        Do not show the progress.
 
index c2d96f4c89ab0fa7207f74a17d0bdf94f8bd3780..1f8aec97d47e3dfb5957ebe29294d881fb22585e 100644 (file)
@@ -153,6 +153,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
                        args.from_promisor = 1;
                        continue;
                }
+               if (!strcmp("--refetch", arg)) {
+                       args.refetch = 1;
+                       continue;
+               }
                if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
                        parse_list_objects_filter(&args.filter_options, arg);
                        continue;
index 0dabef2dd7c565f3f2c2ecd74a0ca295bd874afb..fc75600d4c681a50d32967d2a8517e28410ee168 100644 (file)
@@ -43,6 +43,7 @@ struct options {
                /* see documentation of corresponding flag in fetch-pack.h */
                from_promisor : 1,
 
+               refetch : 1,
                atomic : 1,
                object_format : 1,
                force_if_includes : 1;
@@ -198,6 +199,9 @@ static int set_option(const char *name, const char *value)
        } else if (!strcmp(name, "from-promisor")) {
                options.from_promisor = 1;
                return 0;
+       } else if (!strcmp(name, "refetch")) {
+               options.refetch = 1;
+               return 0;
        } else if (!strcmp(name, "filter")) {
                options.filter = xstrdup(value);
                return 0;
@@ -1182,6 +1186,8 @@ static int fetch_git(struct discovery *heads,
                strvec_push(&args, "--deepen-relative");
        if (options.from_promisor)
                strvec_push(&args, "--from-promisor");
+       if (options.refetch)
+               strvec_push(&args, "--refetch");
        if (options.filter)
                strvec_pushf(&args, "--filter=%s", options.filter);
        strvec_push(&args, url.buf);