X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=sha1-name.c;h=cfe5c874b6f06361b444ec897fddcc36e19979f3;hb=17c8f1f2eda10a972af01b6a909d6586e4114c41;hp=d1cc77c124c11ffd49be472b1368baeda3afbe17;hpb=8f0f46539a8c557985241f3aec7a12bd5f2634c2;p=thirdparty%2Fgit.git diff --git a/sha1-name.c b/sha1-name.c index d1cc77c124..cfe5c874b6 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -442,6 +442,18 @@ static enum get_oid_result get_short_oid(const char *name, int len, find_short_packed_object(&ds); status = finish_object_disambiguation(&ds, oid); + /* + * If we didn't find it, do the usual reprepare() slow-path, + * since the object may have recently been added to the repository + * or migrated from loose to packed. + */ + if (status == MISSING_OBJECT) { + reprepare_packed_git(the_repository); + find_short_object_filename(&ds); + find_short_packed_object(&ds); + status = finish_object_disambiguation(&ds, oid); + } + if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) { struct oid_array collect = OID_ARRAY_INIT; @@ -1820,9 +1832,11 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix) prefix, &oid, &oc); } -int get_oid_with_context(struct repository *repo, const char *str, - unsigned flags, struct object_id *oid, - struct object_context *oc) +enum get_oid_result get_oid_with_context(struct repository *repo, + const char *str, + unsigned flags, + struct object_id *oid, + struct object_context *oc) { if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE) BUG("incompatible flags for get_sha1_with_context");