Skip to content

Commit e106776

Browse files
Kevin Willforddscho
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 <[email protected]>
1 parent bbd201c commit e106776

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

Documentation/config/core.adoc

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

769778
core.sparseCheckout::

connected.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "git-compat-util.h"
44
#include "gettext.h"
5+
#include "gvfs.h"
56
#include "hex.h"
67
#include "odb.h"
78
#include "run-command.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(the_repository, GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK))
54+
return 0;
55+
3756
if (!opt)
3857
opt = &defaults;
3958
transport = opt->transport;

gvfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct repository;
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
int gvfs_config_is_set(struct repository *r, int mask);
1920

t/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ integration_tests = [
691691
't5581-http-curl-verbose.sh',
692692
't5582-fetch-negative-refspec.sh',
693693
't5583-push-branches.sh',
694+
't5584-vfs.sh',
694695
't5600-clone-fail-cleanup.sh',
695696
't5601-clone.sh',
696697
't5602-clone-remote-exec.sh',

t/t5584-vfs.sh

Lines changed: 24 additions & 0 deletions
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)