Message ID | 748f39a9-65aa-2110-cf92-7ddf81b5f507@roku.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mktree: do not check type of remote objects | expand |
Richard Oliver <roliver@roku.com> writes: > As a side note, do you think we need to re-work some uses of the word > 'missing' in the documentation? Some uses of the word, such as in > mktree, predate the concept of promisor remotes. The partial-clone.txt > documentation differentiates between missing "due to a partial clone > or fetch" and missing "due to repository corruption". Would making > such a distinction elsewhere be useful? I do agree with that direction. Back when the world was simpler, there were just "we have the object" and "we ought to have the object but we do not see it", the latter of which was a clear repository corruption. There was no third choice. With the lazy/partial clone stuff, it is not a corrupted repository anymore when certain objects that are reachable during traversal is missing (this is slightly different from a shallow clone in that a shallow history makes the traversal stop early, so at least objects in a shallow clone that are reachable during traversal must exist). So, yes, I think the distinction between "missing but shouldn't be" and "missing by design" is a good thing to keep in mind. Thanks.
Richard Oliver <roliver@roku.com> writes: > + /* Check the type of object identified by oid without fetching objects */ > + struct object_info oi = OBJECT_INFO_INIT; This is -Wdecl-after-statement. > + oi.typep = &obj_type; > + if (oid_object_info_extended(the_repository, &oid, &oi, > + OBJECT_INFO_LOOKUP_REPLACE | > + OBJECT_INFO_QUICK | > + OBJECT_INFO_SKIP_FETCH_OBJECT) < 0) > + obj_type = -1; > + > if (obj_type < 0) { > if (allow_missing) { > ; /* no problem - missing objects are presumed to be of the right type */ I've done an obvious and trivial fix-up locally while queueing. Thanks. diff --git a/builtin/mktree.c b/builtin/mktree.c index cfadb52670..06d81400f5 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -74,6 +74,7 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing) unsigned mode; enum object_type mode_type; /* object type derived from mode */ enum object_type obj_type; /* object type derived from sha */ + struct object_info oi = OBJECT_INFO_INIT; char *path, *to_free = NULL; struct object_id oid; @@ -117,7 +118,6 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing) } /* Check the type of object identified by oid without fetching objects */ - struct object_info oi = OBJECT_INFO_INIT; oi.typep = &obj_type; if (oid_object_info_extended(the_repository, &oid, &oi, OBJECT_INFO_LOOKUP_REPLACE |
diff --git a/builtin/mktree.c b/builtin/mktree.c index 902edba6d2..cfadb52670 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -116,8 +116,15 @@ static void mktree_line(char *buf, int nul_term_line, int allow_missing) path, ptr, type_name(mode_type)); } - /* Check the type of object identified by sha1 */ - obj_type = oid_object_info(the_repository, &oid, NULL); + /* Check the type of object identified by oid without fetching objects */ + struct object_info oi = OBJECT_INFO_INIT; + oi.typep = &obj_type; + if (oid_object_info_extended(the_repository, &oid, &oi, + OBJECT_INFO_LOOKUP_REPLACE | + OBJECT_INFO_QUICK | + OBJECT_INFO_SKIP_FETCH_OBJECT) < 0) + obj_type = -1; + if (obj_type < 0) { if (allow_missing) { ; /* no problem - missing objects are presumed to be of the right type */