]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sha1_name.c
Sync with 2.16.6
[thirdparty/git.git] / sha1_name.c
index e7c18ffc26daf1962f90da9ff5c16cc608149d9d..735c1c0b8ec032b3aac8b6a8976dcdb09ba5e91d 100644 (file)
@@ -542,20 +542,20 @@ static void find_abbrev_len_for_pack(struct packed_git *p,
        /*
         * first is now the position in the packfile where we would insert
         * mad->hash if it does not exist (or the position of mad->hash if
-        * it does exist). Hence, we consider a maximum of three objects
+        * it does exist). Hence, we consider a maximum of two objects
         * nearby for the abbreviation length.
         */
        mad->init_len = 0;
        if (!match) {
-               nth_packed_object_oid(&oid, p, first);
-               extend_abbrev_len(&oid, mad);
+               if (nth_packed_object_oid(&oid, p, first))
+                       extend_abbrev_len(&oid, mad);
        } else if (first < num - 1) {
-               nth_packed_object_oid(&oid, p, first + 1);
-               extend_abbrev_len(&oid, mad);
+               if (nth_packed_object_oid(&oid, p, first + 1))
+                       extend_abbrev_len(&oid, mad);
        }
        if (first > 0) {
-               nth_packed_object_oid(&oid, p, first - 1);
-               extend_abbrev_len(&oid, mad);
+               if (nth_packed_object_oid(&oid, p, first - 1))
+                       extend_abbrev_len(&oid, mad);
        }
        mad->init_len = mad->cur_len;
 }