Skip to content

Commit

Permalink
fetch: use gvfs-helper prefetch under config
Browse files Browse the repository at this point in the history
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 <dstolee@microsoft.com>
  • Loading branch information
derrickstolee authored and dscho committed Aug 16, 2023
1 parent d77fdb2 commit de04271
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,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 builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "string-list.h"
#include "remote.h"
#include "transport.h"
#include "gvfs.h"
#include "gvfs-helper-client.h"
#include "run-command.h"
#include "parse-options.h"
#include "sigchain.h"
Expand Down Expand Up @@ -2369,6 +2371,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
}
string_list_remove_duplicates(&list, 0);

if (core_gvfs & GVFS_PREFETCH_DURING_FETCH)
gh_client__prefetch(0, NULL);

if (negotiate_only) {
struct oidset acked_commits = OIDSET_INIT;
struct oidset_iter iter;
Expand Down
1 change: 1 addition & 0 deletions gvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#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

0 comments on commit de04271

Please sign in to comment.