]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sha1-name.c
Merge branch 'jc/format-patch-error-check'
[thirdparty/git.git] / sha1-name.c
index d1cc77c124c11ffd49be472b1368baeda3afbe17..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;
 
@@ -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");