range-diff: indent the diffs just like tbdiff
[gitweb.git] / sha1-name.c
index 5854bc75fe292949563aabfe715425c1db54d4ca..c9cc1318b7394e86704bda95651c9a4db3015b9a 100644 (file)
@@ -239,7 +239,8 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
                return 0;
 
        /* We need to do this the hard way... */
-       obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
+       obj = deref_tag(the_repository, parse_object(the_repository, oid),
+                       NULL, 0);
        if (obj && obj->type == OBJ_COMMIT)
                return 1;
        return 0;
@@ -263,7 +264,8 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
                return 0;
 
        /* We need to do this the hard way... */
-       obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
+       obj = deref_tag(the_repository, parse_object(the_repository, oid),
+                       NULL, 0);
        if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))
                return 1;
        return 0;
@@ -310,7 +312,7 @@ static int init_object_disambiguation(const char *name, int len,
 {
        int i;
 
-       if (len < MINIMUM_ABBREV || len > GIT_SHA1_HEXSZ)
+       if (len < MINIMUM_ABBREV || len > the_hash_algo->hexsz)
                return -1;
 
        memset(ds, 0, sizeof(*ds));
@@ -576,6 +578,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
        struct disambiguate_state ds;
        struct min_abbrev_data mad;
        struct object_id oid_ret;
+       const unsigned hexsz = the_hash_algo->hexsz;
+
        if (len < 0) {
                unsigned long count = approximate_object_count();
                /*
@@ -599,8 +603,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
        }
 
        oid_to_hex_r(hex, oid);
-       if (len == GIT_SHA1_HEXSZ || !len)
-               return GIT_SHA1_HEXSZ;
+       if (len == hexsz || !len)
+               return hexsz;
 
        mad.init_len = len;
        mad.cur_len = len;
@@ -706,7 +710,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
        int refs_found = 0;
        int at, reflog_len, nth_prior = 0;
 
-       if (len == GIT_SHA1_HEXSZ && !get_oid_hex(str, oid)) {
+       if (len == the_hash_algo->hexsz && !get_oid_hex(str, oid)) {
                if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
                        refs_found = dwim_ref(str, len, &tmp_oid, &real_ref);
                        if (refs_found > 0) {
@@ -750,7 +754,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
                int detached;
 
                if (interpret_nth_prior_checkout(str, len, &buf) > 0) {
-                       detached = (buf.len == GIT_SHA1_HEXSZ && !get_oid_hex(buf.buf, oid));
+                       detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
                        strbuf_release(&buf);
                        if (detached)
                                return 0;
@@ -968,7 +972,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid,
        if (!o)
                return -1;
        if (!expected_type) {
-               o = deref_tag(o, name, sp - name - 2);
+               o = deref_tag(the_repository, o, name, sp - name - 2);
                if (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))
                        return -1;
                oidcpy(oid, &o->oid);
@@ -1100,7 +1104,8 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
        if (!object)
                return 0;
        if (object->type == OBJ_TAG) {
-               object = deref_tag(object, path, strlen(path));
+               object = deref_tag(the_repository, object, path,
+                                  strlen(path));
                if (!object)
                        return 0;
        }
@@ -1650,6 +1655,7 @@ static int get_oid_with_context_1(const char *name,
                        struct commit_list *list = NULL;
 
                        for_each_ref(handle_one_ref, &list);
+                       head_ref(handle_one_ref, &list);
                        commit_list_sort_by_date(&list);
                        return get_oid_oneline(name + 2, oid, list);
                }