Skip to content
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

"gvfs-helper prefetch" during "git fetch" #228

Merged
merged 2 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
5 changes: 5 additions & 0 deletions Documentation/fetch-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -77,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)
{
Expand Down Expand Up @@ -198,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()
};

Expand Down Expand Up @@ -743,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));
Expand Down Expand Up @@ -1824,6 +1832,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);
Expand Down
1 change: 1 addition & 0 deletions gvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down