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>
This commit is contained in:
Kevin Willford 2016-05-30 10:55:53 -04:00 коммит произвёл Johannes Schindelin
Родитель 9994615306
Коммит 0c72508deb
4 изменённых файлов: 53 добавлений и 0 удалений

Просмотреть файл

@ -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::

Просмотреть файл

@ -1,4 +1,5 @@
#include "cache.h"
#include "gvfs.h"
#include "object-store.h"
#include "run-command.h"
#include "sigchain.h"
@ -30,6 +31,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;

1
gvfs.h
Просмотреть файл

@ -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;

24
t/t5583-vfs.sh Executable file
Просмотреть файл

@ -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