Skip to content

Commit bfa97bc

Browse files
Kevin Willforddscho
authored andcommitted
gvfs: add the feature that blobs may be missing
Signed-off-by: Kevin Willford <kewillf@microsoft.com>
1 parent 63e7518 commit bfa97bc

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

Documentation/config/core.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,10 @@ core.gvfs::
752752
GVFS_SKIP_SHA_ON_INDEX::
753753
Bit value 1
754754
Disables the calculation of the sha when writing the index
755+
GVFS_MISSING_OK::
756+
Bit value 4
757+
Normally git write-tree ensures that the objects referenced by the
758+
directory exist in the object database. This option disables this check.
755759
--
756760

757761
core.sparseCheckout::

cache-tree.c

Lines changed: 3 additions & 1 deletion
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 "lockfile.h"
78
#include "tree.h"
89
#include "tree-walk.h"
@@ -260,7 +261,8 @@ static int update_one(struct cache_tree *it,
260261
int flags)
261262
{
262263
struct strbuf buffer;
263-
int missing_ok = flags & WRITE_TREE_MISSING_OK;
264+
int missing_ok = gvfs_config_is_set(GVFS_MISSING_OK) ?
265+
WRITE_TREE_MISSING_OK : (flags & WRITE_TREE_MISSING_OK);
264266
int dryrun = flags & WRITE_TREE_DRY_RUN;
265267
int repair = flags & WRITE_TREE_REPAIR;
266268
int to_invalidate = 0;

commit.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define USE_THE_REPOSITORY_VARIABLE
22

33
#include "git-compat-util.h"
4+
#include "gvfs.h"
45
#include "tag.h"
56
#include "commit.h"
67
#include "commit-graph.h"
@@ -556,13 +557,17 @@ int repo_parse_commit_internal(struct repository *r,
556557
.sizep = &size,
557558
.contentp = &buffer,
558559
};
560+
int ret;
559561
/*
560562
* Git does not support partial clones that exclude commits, so set
561563
* OBJECT_INFO_SKIP_FETCH_OBJECT to fail fast when an object is missing.
562564
*/
563565
int flags = OBJECT_INFO_LOOKUP_REPLACE | OBJECT_INFO_SKIP_FETCH_OBJECT |
564-
OBJECT_INFO_DIE_IF_CORRUPT;
565-
int ret;
566+
OBJECT_INFO_DIE_IF_CORRUPT;
567+
568+
/* But the GVFS Protocol _does_ support missing commits! */
569+
if (gvfs_config_is_set(GVFS_MISSING_OK))
570+
flags ^= OBJECT_INFO_SKIP_FETCH_OBJECT;
566571

567572
if (!item)
568573
return -1;

gvfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* The list of bits in the core_gvfs setting
1313
*/
1414
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
15+
#define GVFS_MISSING_OK (1 << 2)
1516

1617
void gvfs_load_config_value(const char *value);
1718
int gvfs_config_is_set(int mask);

t/t0000-basic.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,11 @@ test_expect_success 'writing this tree with --missing-ok' '
11061106
git write-tree --missing-ok
11071107
'
11081108

1109+
test_expect_success 'writing this tree with missing ok config value' '
1110+
git config core.gvfs 4 &&
1111+
git write-tree
1112+
'
1113+
11091114

11101115
################################################################
11111116
test_expect_success 'git read-tree followed by write-tree should be idempotent' '

0 commit comments

Comments
 (0)