From d4f11868fa3975157b626c2c0f3723c187cfbcc1 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 17 Dec 2019 07:25:40 -0500 Subject: [PATCH 1/2] fetch: use gvfs-helper prefetch under config The gvfs-helper allows us to download prefetch packs using a simple subprocess call. The gvfs-helper-client.h method will automatically compute the timestamp if passing 0, and passing NULL for the number of downloaded packs is valid. Signed-off-by: Derrick Stolee --- Documentation/config/core.txt | 4 ++++ builtin/fetch.c | 5 +++++ gvfs.h | 1 + 3 files changed, 10 insertions(+) diff --git a/Documentation/config/core.txt b/Documentation/config/core.txt index 4d1fd4f2daf4ee..efec95cacc07a7 100644 --- a/Documentation/config/core.txt +++ b/Documentation/config/core.txt @@ -659,6 +659,10 @@ core.gvfs:: is first accessed and brought down to the client. Git.exe can't currently tell the first access vs subsequent accesses so this flag just blocks them from occurring at all. + GVFS_PREFETCH_DURING_FETCH:: + Bit value 128 + While performing a `git fetch` command, use the gvfs-helper to + perform a "prefetch" of commits and trees. -- core.useGvfsHelper:: diff --git a/builtin/fetch.c b/builtin/fetch.c index 863c858fde9afb..00c045b60f20a8 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -27,6 +27,8 @@ #include "branch.h" #include "promisor-remote.h" #include "commit-graph.h" +#include "gvfs.h" +#include "gvfs-helper-client.h" #define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000) @@ -1824,6 +1826,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) fetch_if_missing = 0; + if (core_gvfs & GVFS_PREFETCH_DURING_FETCH) + gh_client__prefetch(0, NULL); + if (remote) { if (filter_options.choice || has_promisor_remote()) fetch_one_setup_partial(remote); diff --git a/gvfs.h b/gvfs.h index e193502151467a..7d999f3e8d234f 100644 --- a/gvfs.h +++ b/gvfs.h @@ -17,6 +17,7 @@ #define GVFS_NO_DELETE_OUTSIDE_SPARSECHECKOUT (1 << 3) #define GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK (1 << 4) #define GVFS_BLOCK_FILTERS_AND_EOL_CONVERSIONS (1 << 6) +#define GVFS_PREFETCH_DURING_FETCH (1 << 7) void gvfs_load_config_value(const char *value); int gvfs_config_is_set(int mask); From 7f8481bc1436f3fbbde67adc8e30b22e65ca6756 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 17 Dec 2019 07:43:19 -0500 Subject: [PATCH 2/2] fetch: add --no-update-remote-refs To allow running "git fetch" in the background, we want to ensure that users still see when the remote refs update in their user- facing fetch commands. Use a new --no-update-remote-refs option to prevent storing these updates to refs/remotes. Signed-off-by: Derrick Stolee --- Documentation/fetch-options.txt | 5 +++++ builtin/fetch.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 43b9ff3bce218e..ebf32b49ebbb43 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -250,6 +250,11 @@ endif::git-pull[] 'git-pull' the --ff-only option will still check for forced updates before attempting a fast-forward update. See linkgit:git-config[1]. +--no-update-remote-refs:: + By default, git updates the `refs/remotes/` refspace with the refs + advertised by the remotes during a `git fetch` command. With this + option, those refs will be ignored. + -4:: --ipv4:: Use IPv4 addresses only, ignoring IPv6 addresses. diff --git a/builtin/fetch.c b/builtin/fetch.c index 00c045b60f20a8..2e8d2bc664a2cc 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -79,6 +79,7 @@ static struct refspec refmap = REFSPEC_INIT_FETCH; static struct list_objects_filter_options filter_options; static struct string_list server_options = STRING_LIST_INIT_DUP; static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP; +static int update_remote_refs = 1; static int git_fetch_config(const char *k, const char *v, void *cb) { @@ -200,6 +201,8 @@ static struct option builtin_fetch_options[] = { N_("run 'gc --auto' after fetching")), OPT_BOOL(0, "show-forced-updates", &fetch_show_forced_updates, N_("check for forced-updates on all updated branches")), + OPT_BOOL(0, "update-remote-refs", &update_remote_refs, + N_("update the refs/remotes/ refspace")), OPT_END() }; @@ -745,6 +748,9 @@ static int update_local_ref(struct ref *ref, const char *pretty_ref = prettify_refname(ref->name); int fast_forward = 0; + if (!update_remote_refs && starts_with(ref->name, "refs/remotes/")) + return 0; + type = oid_object_info(the_repository, &ref->new_oid, NULL); if (type < 0) die(_("object %s not found"), oid_to_hex(&ref->new_oid));