]> gitweb.ps.run Git - ps-cgit/blobdiff - shared.c
git: update to v2.15.1
[ps-cgit] / shared.c
index 571fbba6cb67ba6d623e544348d58380e168d614..df3f61160784eb7ab7c3aea9f185bdc6fb0d35de 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -142,37 +142,6 @@ void strbuf_ensure_end(struct strbuf *sb, char c)
                strbuf_addch(sb, c);
 }
 
-char *strlpart(char *txt, int maxlen)
-{
-       char *result;
-
-       if (!txt)
-               return txt;
-
-       if (strlen(txt) <= maxlen)
-               return txt;
-       result = xmalloc(maxlen + 1);
-       memcpy(result, txt, maxlen - 3);
-       result[maxlen-1] = result[maxlen-2] = result[maxlen-3] = '.';
-       result[maxlen] = '\0';
-       return result;
-}
-
-char *strrpart(char *txt, int maxlen)
-{
-       char *result;
-
-       if (!txt)
-               return txt;
-
-       if (strlen(txt) <= maxlen)
-               return txt;
-       result = xmalloc(maxlen + 1);
-       memcpy(result + 3, txt + strlen(txt) - maxlen + 4, maxlen - 3);
-       result[0] = result[1] = result[2] = '.';
-       return result;
-}
-
 void cgit_add_ref(struct reflist *list, struct refinfo *ref)
 {
        size_t size;
@@ -191,7 +160,7 @@ static struct refinfo *cgit_mk_refinfo(const char *refname, const struct object_
 
        ref = xmalloc(sizeof (struct refinfo));
        ref->refname = xstrdup(refname);
-       ref->object = parse_object(oid->hash);
+       ref->object = parse_object(oid);
        switch (ref->object->type) {
        case OBJ_TAG:
                ref->tag = cgit_parse_tag((struct tag *)ref->object);
@@ -383,7 +352,7 @@ void cgit_diff_tree(const struct object_id *old_oid,
        opt.format_callback = cgit_diff_tree_cb;
        opt.format_callback_data = fn;
        if (prefix) {
-               item.match = prefix;
+               item.match = xstrdup(prefix);
                item.len = strlen(prefix);
                opt.pathspec.nr = 1;
                opt.pathspec.items = &item;
@@ -391,11 +360,13 @@ void cgit_diff_tree(const struct object_id *old_oid,
        diff_setup_done(&opt);
 
        if (old_oid && !is_null_oid(old_oid))
-               diff_tree_sha1(old_oid->hash, new_oid->hash, "", &opt);
+               diff_tree_oid(old_oid, new_oid, "", &opt);
        else
-               diff_root_tree_sha1(new_oid->hash, "", &opt);
+               diff_root_tree_oid(new_oid, "", &opt);
        diffcore_std(&opt);
        diff_flush(&opt);
+
+       free(item.match);
 }
 
 void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)