Merge branch 'jh/fsck-promisors'
In preparation for implementing narrow/partial clone, the machinery for checking object connectivity used by gc and fsck has been taught that a missing object is OK when it is referenced by a packfile specially marked as coming from trusted repository that promises to make them available on-demand and lazily. * jh/fsck-promisors: gc: do not repack promisor packfiles rev-list: support termination at promisor objects sha1_file: support lazily fetching missing objects introduce fetch-object: fetch one promisor object index-pack: refactor writing of .keep files fsck: support promisor objects as CLI argument fsck: support referenced promisor objects fsck: support refs pointing to promisor objects fsck: introduce partialclone extension extension.partialclone: introduce partial clone extension
This commit is contained in:
@ -149,6 +149,15 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
|
||||
if (obj->flags & REACHABLE)
|
||||
return 0;
|
||||
obj->flags |= REACHABLE;
|
||||
|
||||
if (is_promisor_object(&obj->oid))
|
||||
/*
|
||||
* Further recursion does not need to be performed on this
|
||||
* object since it is a promisor object (so it does not need to
|
||||
* be added to "pending").
|
||||
*/
|
||||
return 0;
|
||||
|
||||
if (!(obj->flags & HAS_OBJ)) {
|
||||
if (parent && !has_object_file(&obj->oid)) {
|
||||
printf("broken link from %7s %s\n",
|
||||
@ -208,6 +217,8 @@ static void check_reachable_object(struct object *obj)
|
||||
* do a full fsck
|
||||
*/
|
||||
if (!(obj->flags & HAS_OBJ)) {
|
||||
if (is_promisor_object(&obj->oid))
|
||||
return;
|
||||
if (has_sha1_pack(obj->oid.hash))
|
||||
return; /* it is in pack - forget about it */
|
||||
printf("missing %s %s\n", printable_type(obj),
|
||||
@ -398,7 +409,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
|
||||
xstrfmt("%s@{%"PRItime"}", refname, timestamp));
|
||||
obj->flags |= USED;
|
||||
mark_object_reachable(obj);
|
||||
} else {
|
||||
} else if (!is_promisor_object(oid)) {
|
||||
error("%s: invalid reflog entry %s", refname, oid_to_hex(oid));
|
||||
errors_found |= ERROR_REACHABLE;
|
||||
}
|
||||
@ -434,6 +445,14 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
|
||||
|
||||
obj = parse_object(oid);
|
||||
if (!obj) {
|
||||
if (is_promisor_object(oid)) {
|
||||
/*
|
||||
* Increment default_refs anyway, because this is a
|
||||
* valid ref.
|
||||
*/
|
||||
default_refs++;
|
||||
return 0;
|
||||
}
|
||||
error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
|
||||
errors_found |= ERROR_REACHABLE;
|
||||
/* We'll continue with the rest despite the error.. */
|
||||
@ -659,6 +678,9 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
|
||||
int i;
|
||||
struct alternate_object_database *alt;
|
||||
|
||||
/* fsck knows how to handle missing promisor objects */
|
||||
fetch_if_missing = 0;
|
||||
|
||||
errors_found = 0;
|
||||
check_replace_refs = 0;
|
||||
|
||||
@ -731,6 +753,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
|
||||
struct object *obj = lookup_object(oid.hash);
|
||||
|
||||
if (!obj || !(obj->flags & HAS_OBJ)) {
|
||||
if (is_promisor_object(&oid))
|
||||
continue;
|
||||
error("%s: object missing", oid_to_hex(&oid));
|
||||
errors_found |= ERROR_OBJECT;
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user