Skip to content

Commit 1d54ae4

Browse files
Kevin Willforddscho
authored andcommitted
gvfs: add the feature that blobs may be missing
Signed-off-by: Kevin Willford <[email protected]>
1 parent 85df70d commit 1d54ae4

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
@@ -751,6 +751,10 @@ core.gvfs::
751751
GVFS_SKIP_SHA_ON_INDEX::
752752
Bit value 1
753753
Disables the calculation of the sha when writing the index
754+
GVFS_MISSING_OK::
755+
Bit value 4
756+
Normally git write-tree ensures that the objects referenced by the
757+
directory exist in the object database. This option disables this check.
754758
--
755759

756760
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"
@@ -263,7 +264,8 @@ static int update_one(struct cache_tree *it,
263264
int flags)
264265
{
265266
struct strbuf buffer;
266-
int missing_ok = flags & WRITE_TREE_MISSING_OK;
267+
int missing_ok = gvfs_config_is_set(the_repository, GVFS_MISSING_OK) ?
268+
WRITE_TREE_MISSING_OK : (flags & WRITE_TREE_MISSING_OK);
267269
int dryrun = flags & WRITE_TREE_DRY_RUN;
268270
int repair = flags & WRITE_TREE_REPAIR;
269271
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"
@@ -558,13 +559,17 @@ int repo_parse_commit_internal(struct repository *r,
558559
.sizep = &size,
559560
.contentp = &buffer,
560561
};
562+
int ret;
561563
/*
562564
* Git does not support partial clones that exclude commits, so set
563565
* OBJECT_INFO_SKIP_FETCH_OBJECT to fail fast when an object is missing.
564566
*/
565567
int flags = OBJECT_INFO_LOOKUP_REPLACE | OBJECT_INFO_SKIP_FETCH_OBJECT |
566-
OBJECT_INFO_DIE_IF_CORRUPT;
567-
int ret;
568+
OBJECT_INFO_DIE_IF_CORRUPT;
569+
570+
/* But the GVFS Protocol _does_ support missing commits! */
571+
if (gvfs_config_is_set(r, GVFS_MISSING_OK))
572+
flags ^= OBJECT_INFO_SKIP_FETCH_OBJECT;
568573

569574
if (!item)
570575
return -1;

gvfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct repository;
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
int gvfs_config_is_set(struct repository *r, int mask);
1718

t/t0000-basic.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,11 @@ test_expect_success 'writing this tree with --missing-ok' '
11091109
git write-tree --missing-ok
11101110
'
11111111

1112+
test_expect_success 'writing this tree with missing ok config value' '
1113+
git config core.gvfs 4 &&
1114+
git write-tree
1115+
'
1116+
11121117

11131118
################################################################
11141119
test_expect_success 'git read-tree followed by write-tree should be idempotent' '

0 commit comments

Comments
 (0)