]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sha1-name.c
Merge branch 'jh/midx-verify-too-many-packs'
[thirdparty/git.git] / sha1-name.c
index 6dda2c16df1026e50b7d9be255b6bbfc4e92725c..cfe5c874b6f06361b444ec897fddcc36e19979f3 100644 (file)
@@ -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;