]> git.cameronkatri.com Git - cgit.git/blobdiff - shared.c
doc: use consistent id's when generating html files
[cgit.git] / shared.c
index 8d084353afa36d353a078a8636ede372850a6a5b..21ac8f4e68ea34b9ff0d95eb80612ed38404d21b 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -142,22 +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;
-}
-
 void cgit_add_ref(struct reflist *list, struct refinfo *ref)
 {
        size_t size;
@@ -176,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);
@@ -362,13 +346,13 @@ void cgit_diff_tree(const struct object_id *old_oid,
        opt.output_format = DIFF_FORMAT_CALLBACK;
        opt.detect_rename = 1;
        opt.rename_limit = ctx.cfg.renamelimit;
-       DIFF_OPT_SET(&opt, RECURSIVE);
+       opt.flags.recursive = 1;
        if (ignorews)
                DIFF_XDL_SET(&opt, IGNORE_WHITESPACE);
        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;
@@ -376,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)