Skip to content

Commit cb2780d

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 <kewillf@microsoft.com>
1 parent 53f990b commit cb2780d

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

Documentation/config/core.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,15 @@ core.gvfs::
750750
directory. This will allow virtualized working directories to
751751
detect the change to HEAD and use the new commit tree to show
752752
the files that are in the working directory.
753+
GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK::
754+
Bit value 16
755+
While performing a fetch with a virtual file system we know
756+
that there will be missing objects and we don't want to download
757+
them just because of the reachability of the commits. We also
758+
don't want to download a pack file with commits, trees, and blobs
759+
since these will be downloaded on demand. This flag will skip the
760+
checks on the reachability of objects during a fetch as well as
761+
the upload pack so that extraneous objects don't get downloaded.
753762
--
754763

755764
core.sparseCheckout::

connected.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "cache.h"
2+
#include "gvfs.h"
23
#include "object-store.h"
34
#include "run-command.h"
45
#include "sigchain.h"
@@ -30,6 +31,24 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
3031
struct transport *transport;
3132
size_t base_len;
3233

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

gvfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
1717
#define GVFS_MISSING_OK (1 << 2)
1818
#define GVFS_NO_DELETE_OUTSIDE_SPARSECHECKOUT (1 << 3)
19+
#define GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK (1 << 4)
1920

2021
static inline int gvfs_config_is_set(int mask) {
2122
return (core_gvfs & mask) == mask;

t/t5583-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)