Code

gitview.txt: improve asciidoc markup
[git.git] / sha1_name.c
index f2cbafa496231e7a9cdbbea2ab4e7d4c4ed761ab..e9eb6ce882ea92523c9a871c7581457af2dc78c5 100644 (file)
@@ -84,7 +84,7 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne
                        int cmp;
 
                        nth_packed_object_sha1(p, mid, now);
-                       cmp = memcmp(match, now, 20);
+                       cmp = hashcmp(match, now);
                        if (!cmp) {
                                first = mid;
                                break;
@@ -106,7 +106,7 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne
                                                memcpy(found_sha1, now, 20);
                                                found++;
                                        }
-                                       else if (memcmp(found_sha1, now, 20)) {
+                                       else if (hashcmp(found_sha1, now)) {
                                                found = 2;
                                                break;
                                        }
@@ -144,7 +144,7 @@ static int find_unique_short_object(int len, char *canonical,
                return 0;
        }
        /* Both have unique ones -- do they match? */
-       if (memcmp(packed_sha1, unpacked_sha1, 20))
+       if (hashcmp(packed_sha1, unpacked_sha1))
                return SHORT_NAME_AMBIGUOUS;
        memcpy(sha1, packed_sha1, 20);
        return 0;
@@ -191,9 +191,9 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
        int status, is_null;
        static char hex[41];
 
-       is_null = !memcmp(sha1, null_sha1, 20);
+       is_null = is_null_sha1(sha1);
        memcpy(hex, sha1_to_hex(sha1), 40);
-       if (len == 40)
+       if (len == 40 || !len)
                return hex;
        while (len < 40) {
                unsigned char sha1_ret[20];
@@ -381,13 +381,13 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
 
        sp++; /* beginning of type name, or closing brace for empty */
        if (!strncmp(commit_type, sp, 6) && sp[6] == '}')
-               expected_type = TYPE_COMMIT;
+               expected_type = OBJ_COMMIT;
        else if (!strncmp(tree_type, sp, 4) && sp[4] == '}')
-               expected_type = TYPE_TREE;
+               expected_type = OBJ_TREE;
        else if (!strncmp(blob_type, sp, 4) && sp[4] == '}')
-               expected_type = TYPE_BLOB;
+               expected_type = OBJ_BLOB;
        else if (sp[0] == '}')
-               expected_type = TYPE_NONE;
+               expected_type = OBJ_NONE;
        else
                return -1;
 
@@ -416,9 +416,9 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
                                memcpy(sha1, o->sha1, 20);
                                return 0;
                        }
-                       if (o->type == TYPE_TAG)
+                       if (o->type == OBJ_TAG)
                                o = ((struct tag*) o)->tagged;
-                       else if (o->type == TYPE_COMMIT)
+                       else if (o->type == OBJ_COMMIT)
                                o = &(((struct commit *) o)->tree->object);
                        else
                                return error("%.*s: expected %s type, but the object dereferences to %s type",