Skip to content

Commit b00139b

Browse files
Kevin Willfordmjcheetham
authored andcommitted
gvfs: add the feature that blobs may be missing
Signed-off-by: Kevin Willford <[email protected]>
1 parent 8e016a5 commit b00139b

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

Documentation/config/core.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@ core.gvfs::
746746
GVFS_SKIP_SHA_ON_INDEX::
747747
Bit value 1
748748
Disables the calculation of the sha when writing the index
749+
GVFS_MISSING_OK::
750+
Bit value 4
751+
Normally git write-tree ensures that the objects referenced by the
752+
directory exist in the object database. This option disables this check.
749753
--
750754

751755
core.sparseCheckout::

cache-tree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "git-compat-util.h"
55
#include "gettext.h"
66
#include "hex.h"
7+
#include "gvfs.h"
78
#include "lockfile.h"
89
#include "tree.h"
910
#include "tree-walk.h"
@@ -261,7 +262,8 @@ static int update_one(struct cache_tree *it,
261262
int flags)
262263
{
263264
struct strbuf buffer;
264-
int missing_ok = flags & WRITE_TREE_MISSING_OK;
265+
int missing_ok = gvfs_config_is_set(GVFS_MISSING_OK) ?
266+
WRITE_TREE_MISSING_OK : (flags & WRITE_TREE_MISSING_OK);
265267
int dryrun = flags & WRITE_TREE_DRY_RUN;
266268
int repair = flags & WRITE_TREE_REPAIR;
267269
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)