Skip to content

Commit a9b99d3

Browse files
Kevin Willfordvdye
authored andcommitted
gvfs: add the feature that blobs may be missing
Signed-off-by: Kevin Willford <kewillf@microsoft.com>
1 parent 854652c commit a9b99d3

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
@@ -737,6 +737,10 @@ core.gvfs::
737737
GVFS_SKIP_SHA_ON_INDEX::
738738
Bit value 1
739739
Disables the calculation of the sha when writing the index
740+
GVFS_MISSING_OK::
741+
Bit value 4
742+
Normally git write-tree ensures that the objects referenced by the
743+
directory exist in the object database. This option disables this check.
740744
--
741745

742746
core.sparseCheckout::

cache-tree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "alloc.h"
33
#include "environment.h"
44
#include "hex.h"
5+
#include "gvfs.h"
56
#include "lockfile.h"
67
#include "tree.h"
78
#include "tree-walk.h"
@@ -258,7 +259,8 @@ static int update_one(struct cache_tree *it,
258259
int flags)
259260
{
260261
struct strbuf buffer;
261-
int missing_ok = flags & WRITE_TREE_MISSING_OK;
262+
int missing_ok = gvfs_config_is_set(GVFS_MISSING_OK) ?
263+
WRITE_TREE_MISSING_OK : (flags & WRITE_TREE_MISSING_OK);
262264
int dryrun = flags & WRITE_TREE_DRY_RUN;
263265
int repair = flags & WRITE_TREE_REPAIR;
264266
int to_invalidate = 0;

commit.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "git-compat-util.h"
2+
#include "gvfs.h"
23
#include "tag.h"
34
#include "commit.h"
45
#include "commit-graph.h"
@@ -560,13 +561,17 @@ int repo_parse_commit_internal(struct repository *r,
560561
.sizep = &size,
561562
.contentp = &buffer,
562563
};
564+
int ret;
563565
/*
564566
* Git does not support partial clones that exclude commits, so set
565567
* OBJECT_INFO_SKIP_FETCH_OBJECT to fail fast when an object is missing.
566568
*/
567569
int flags = OBJECT_INFO_LOOKUP_REPLACE | OBJECT_INFO_SKIP_FETCH_OBJECT |
568-
OBJECT_INFO_DIE_IF_CORRUPT;
569-
int ret;
570+
OBJECT_INFO_DIE_IF_CORRUPT;
571+
572+
/* But the GVFS Protocol _does_ support missing commits! */
573+
if (gvfs_config_is_set(GVFS_MISSING_OK))
574+
flags ^= OBJECT_INFO_SKIP_FETCH_OBJECT;
570575

571576
if (!item)
572577
return -1;

gvfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* The list of bits in the core_gvfs setting
1515
*/
1616
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
17+
#define GVFS_MISSING_OK (1 << 2)
1718

1819
static inline int gvfs_config_is_set(int mask) {
1920
return (core_gvfs & mask) == 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)