Skip to content

Commit dc7f44e

Browse files
Kevin Willforddscho
Kevin Willford
authored andcommitted
gvfs: optionally skip reachability checks/upload pack during fetch
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>
1 parent ad33b6a commit dc7f44e

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

Diff for: Documentation/config/core.txt

+9
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,15 @@ core.gvfs::
765765
directory. This will allow virtualized working directories to
766766
detect the change to HEAD and use the new commit tree to show
767767
the files that are in the working directory.
768+
GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK::
769+
Bit value 16
770+
While performing a fetch with a virtual file system we know
771+
that there will be missing objects and we don't want to download
772+
them just because of the reachability of the commits. We also
773+
don't want to download a pack file with commits, trees, and blobs
774+
since these will be downloaded on demand. This flag will skip the
775+
checks on the reachability of objects during a fetch as well as
776+
the upload pack so that extraneous objects don't get downloaded.
768777
--
769778

770779
core.sparseCheckout::

Diff for: connected.c

+19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "git-compat-util.h"
44
#include "gettext.h"
55
#include "hex.h"
6+
#include "gvfs.h"
67
#include "object-store-ll.h"
78
#include "run-command.h"
89
#include "sigchain.h"
@@ -34,6 +35,24 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
3435
struct transport *transport;
3536
size_t base_len;
3637

38+
/*
39+
* Running a virtual file system there will be objects that are
40+
* missing locally and we don't want to download a bunch of
41+
* commits, trees, and blobs just to make sure everything is
42+
* reachable locally so this option will skip reachablility
43+
* checks below that use rev-list. This will stop the check
44+
* before uploadpack runs to determine if there is anything to
45+
* fetch. Returning zero for the first check will also prevent the
46+
* uploadpack from happening. It will also skip the check after
47+
* the fetch is finished to make sure all the objects where
48+
* downloaded in the pack file. This will allow the fetch to
49+
* run and get all the latest tip commit ids for all the branches
50+
* in the fetch but not pull down commits, trees, or blobs via
51+
* upload pack.
52+
*/
53+
if (gvfs_config_is_set(GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK))
54+
return 0;
55+
3756
if (!opt)
3857
opt = &defaults;
3958
transport = opt->transport;

Diff for: gvfs.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
1515
#define GVFS_MISSING_OK (1 << 2)
1616
#define GVFS_NO_DELETE_OUTSIDE_SPARSECHECKOUT (1 << 3)
17+
#define GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK (1 << 4)
1718

1819
void gvfs_load_config_value(const char *value);
1920
int gvfs_config_is_set(int mask);

Diff for: t/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ integration_tests = [
705705
't5581-http-curl-verbose.sh',
706706
't5582-fetch-negative-refspec.sh',
707707
't5583-push-branches.sh',
708+
't5584-vfs.sh',
708709
't5600-clone-fail-cleanup.sh',
709710
't5601-clone.sh',
710711
't5602-clone-remote-exec.sh',

Diff for: t/t5584-vfs.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
test_description='fetch using the flag to skip reachability and upload pack'
4+
5+
. ./test-lib.sh
6+
7+
8+
test_expect_success setup '
9+
echo inital >a &&
10+
git add a &&
11+
git commit -m initial &&
12+
git clone . one
13+
'
14+
15+
test_expect_success "fetch test" '
16+
cd one &&
17+
git config core.gvfs 16 &&
18+
rm -rf .git/objects/* &&
19+
git -C .. cat-file commit HEAD | git hash-object -w --stdin -t commit &&
20+
git fetch &&
21+
test_must_fail git rev-parse --verify HEAD^{tree}
22+
'
23+
24+
test_done

0 commit comments

Comments
 (0)