rev-list: allow -<n> as shorthand for --max-count=<n>
[git.git] / sha1_name.c
index 67b69a5..ba0747c 100644 (file)
@@ -143,7 +143,7 @@ static int find_unique_short_object(int len, char *canonical,
        }
        /* Both have unique ones -- do they match? */
        if (memcmp(packed_sha1, unpacked_sha1, 20))
-               return -2;
+               return SHORT_NAME_AMBIGUOUS;
        memcpy(sha1, packed_sha1, 20);
        return 0;
 }
@@ -155,7 +155,7 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
        char canonical[40];
        unsigned char res[20];
 
-       if (len < 4)
+       if (len < MINIMUM_ABBREV)
                return -1;
        memset(res, 0, 20);
        memset(canonical, 'x', 40);
@@ -188,7 +188,10 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
 {
        int status;
        static char hex[41];
+
        memcpy(hex, sha1_to_hex(sha1), 40);
+       if (len == 40)
+               return hex;
        while (len < 40) {
                unsigned char sha1_ret[20];
                status = get_short_sha1(hex, len, sha1_ret, 1);