Skip to content

Commit

Permalink
gvfs: optionally skip reachability checks/upload pack during fetch
Browse files Browse the repository at this point in the history
While performing a fetch with a virtual file system we know that there
will be missing objects and we don't want to download them just because
of the reachability of the commits.  We also don't want to download a
pack file with commits, trees, and blobs since these will be downloaded
on demand.

This flag will skip the first connectivity check and by returning zero
will skip the upload pack. It will also skip the second connectivity
check but continue to update the branches to the latest commit ids.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
  • Loading branch information
Kevin Willford authored and vdye committed Jul 19, 2023
1 parent 68851a7 commit d6b7b96
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,15 @@ core.gvfs::
directory. This will allow virtualized working directories to
detect the change to HEAD and use the new commit tree to show
the files that are in the working directory.
GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK::
Bit value 16
While performing a fetch with a virtual file system we know
that there will be missing objects and we don't want to download
them just because of the reachability of the commits. We also
don't want to download a pack file with commits, trees, and blobs
since these will be downloaded on demand. This flag will skip the
checks on the reachability of objects during a fetch as well as
the upload pack so that extraneous objects don't get downloaded.
--

core.sparseCheckout::
Expand Down
19 changes: 19 additions & 0 deletions connected.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "git-compat-util.h"
#include "gettext.h"
#include "hex.h"
#include "gvfs.h"
#include "object-store.h"
#include "run-command.h"
#include "sigchain.h"
Expand Down Expand Up @@ -32,6 +33,24 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
struct transport *transport;
size_t base_len;

/*
* Running a virtual file system there will be objects that are
* missing locally and we don't want to download a bunch of
* commits, trees, and blobs just to make sure everything is
* reachable locally so this option will skip reachablility
* checks below that use rev-list. This will stop the check
* before uploadpack runs to determine if there is anything to
* fetch. Returning zero for the first check will also prevent the
* uploadpack from happening. It will also skip the check after
* the fetch is finished to make sure all the objects where
* downloaded in the pack file. This will allow the fetch to
* run and get all the latest tip commit ids for all the branches
* in the fetch but not pull down commits, trees, or blobs via
* upload pack.
*/
if (gvfs_config_is_set(GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK))
return 0;

if (!opt)
opt = &defaults;
transport = opt->transport;
Expand Down
1 change: 1 addition & 0 deletions gvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
#define GVFS_MISSING_OK (1 << 2)
#define GVFS_NO_DELETE_OUTSIDE_SPARSECHECKOUT (1 << 3)
#define GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK (1 << 4)

static inline int gvfs_config_is_set(int mask) {
return (core_gvfs & mask) == mask;
Expand Down
24 changes: 24 additions & 0 deletions t/t5584-vfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

test_description='fetch using the flag to skip reachability and upload pack'

. ./test-lib.sh


test_expect_success setup '
echo inital >a &&
git add a &&
git commit -m initial &&
git clone . one
'

test_expect_success "fetch test" '
cd one &&
git config core.gvfs 16 &&
rm -rf .git/objects/* &&
git -C .. cat-file commit HEAD | git hash-object -w --stdin -t commit &&
git fetch &&
test_must_fail git rev-parse --verify HEAD^{tree}
'

test_done

0 comments on commit d6b7b96

Please sign in to comment.