<p dir="ltr">You've added a bunch of fprintf(stderr, "debugging blah...") in this commit that I missed the first time through. Could you post a patch which removes these?</p>
<p dir="ltr">--<br>
Sent from my telephone.</p>
<div class="gmail_quote">On May 29, 2014 5:53 PM, "Christian Hesse" <<a href="mailto:mail@eworm.de">mail@eworm.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
prefixcmp() and suffixcmp() have been remove, functionality is now<br>
provided by starts_with() and ends_with(). Retrurn values have been<br>
changed, so instead of just renaming we have to fix logic.<br>
Everything else looks just fine.<br>
---<br>
 Makefile      |  2 +-<br>
 cgit.c        | 26 +++++++++++++-------------<br>
 git           |  2 +-<br>
 parsing.c     | 12 ++++++------<br>
 scan-tree.c   | 10 +++++++---<br>
 ui-clone.c    |  2 +-<br>
 ui-log.c      |  8 ++++----<br>
 ui-refs.c     |  6 +++---<br>
 ui-repolist.c |  2 +-<br>
 ui-shared.c   |  2 +-<br>
 ui-snapshot.c |  4 ++--<br>
 ui-summary.c  |  2 +-<br>
 12 files changed, 41 insertions(+), 37 deletions(-)<br>
<br>
diff --git a/Makefile b/Makefile<br>
index e6ec0dc..0223a17 100644<br>
--- a/Makefile<br>
+++ b/Makefile<br>
@@ -14,7 +14,7 @@ htmldir = $(docdir)<br>
 pdfdir = $(docdir)<br>
 mandir = $(prefix)/share/man<br>
 SHA1_HEADER = <openssl/sha.h><br>
-GIT_VER = 1.9.2<br>
+GIT_VER = 2.0.0<br>
 GIT_URL = <a href="https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz" target="_blank">https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz</a><br>
 INSTALL = install<br>
 COPYTREE = cp -r<br>
diff --git a/cgit.c b/cgit.c<br>
index f488ebf..20f6e27 100644<br>
--- a/cgit.c<br>
+++ b/cgit.c<br>
@@ -69,7 +69,7 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va<br>
                repo->max_stats = cgit_find_stats_period(value, NULL);<br>
        else if (!strcmp(name, "module-link"))<br>
                repo->module_link= xstrdup(value);<br>
-       else if (!prefixcmp(name, "module-link.")) {<br>
+       else if (starts_with(name, "module-link.")) {<br>
                item = string_list_append(&repo->submodules, xstrdup(name + 12));<br>
                item->util = xstrdup(value);<br>
        } else if (!strcmp(name, "section"))<br>
@@ -102,7 +102,7 @@ static void config_cb(const char *name, const char *value)<br>
                ctx.repo = cgit_add_repo(value);<br>
        else if (ctx.repo && !strcmp(name, "repo.path"))<br>
                ctx.repo->path = trim_end(value, '/');<br>
-       else if (ctx.repo && !prefixcmp(name, "repo."))<br>
+       else if (ctx.repo && starts_with(name, "repo."))<br>
                repo_config(ctx.repo, name + 5, value);<br>
        else if (!strcmp(name, "readme") && value != NULL)<br>
                string_list_append(&ctx.cfg.readme, xstrdup(value));<br>
@@ -264,7 +264,7 @@ static void config_cb(const char *name, const char *value)<br>
                        ctx.cfg.branch_sort = 1;<br>
                if (!strcmp(value, "name"))<br>
                        ctx.cfg.branch_sort = 0;<br>
-       } else if (!prefixcmp(name, "mimetype."))<br>
+       } else if (starts_with(name, "mimetype."))<br>
                add_mimetype(name + 9, value);<br>
        else if (!strcmp(name, "include"))<br>
                parse_configfile(expand_macros(value), config_cb);<br>
@@ -454,7 +454,7 @@ static char *guess_defbranch(void)<br>
        unsigned char sha1[20];<br>
<br>
        ref = resolve_ref_unsafe("HEAD", sha1, 0, NULL);<br>
-       if (!ref || prefixcmp(ref, "refs/heads/"))<br>
+       if (!ref || !starts_with(ref, "refs/heads/"))<br>
                return "master";<br>
        return xstrdup(ref + 11);<br>
 }<br>
@@ -941,28 +941,28 @@ static void cgit_parse_args(int argc, const char **argv)<br>
<br>
                        exit(0);<br>
                }<br>
-               if (!prefixcmp(argv[i], "--cache=")) {<br>
+               if (starts_with(argv[i], "--cache=")) {<br>
                        ctx.cfg.cache_root = xstrdup(argv[i] + 8);<br>
                } else if (!strcmp(argv[i], "--nocache")) {<br>
                        ctx.cfg.nocache = 1;<br>
                } else if (!strcmp(argv[i], "--nohttp")) {<br>
                        ctx.env.no_http = "1";<br>
-               } else if (!prefixcmp(argv[i], "--query=")) {<br>
+               } else if (starts_with(argv[i], "--query=")) {<br>
                        ctx.qry.raw = xstrdup(argv[i] + 8);<br>
-               } else if (!prefixcmp(argv[i], "--repo=")) {<br>
+               } else if (starts_with(argv[i], "--repo=")) {<br>
                        ctx.qry.repo = xstrdup(argv[i] + 7);<br>
-               } else if (!prefixcmp(argv[i], "--page=")) {<br>
+               } else if (starts_with(argv[i], "--page=")) {<br>
                        ctx.qry.page = xstrdup(argv[i] + 7);<br>
-               } else if (!prefixcmp(argv[i], "--head=")) {<br>
+               } else if (starts_with(argv[i], "--head=")) {<br>
                        ctx.qry.head = xstrdup(argv[i] + 7);<br>
                        ctx.qry.has_symref = 1;<br>
-               } else if (!prefixcmp(argv[i], "--sha1=")) {<br>
+               } else if (starts_with(argv[i], "--sha1=")) {<br>
                        ctx.qry.sha1 = xstrdup(argv[i] + 7);<br>
                        ctx.qry.has_sha1 = 1;<br>
-               } else if (!prefixcmp(argv[i], "--ofs=")) {<br>
+               } else if (starts_with(argv[i], "--ofs=")) {<br>
                        ctx.qry.ofs = atoi(argv[i] + 6);<br>
-               } else if (!prefixcmp(argv[i], "--scan-tree=") ||<br>
-                          !prefixcmp(argv[i], "--scan-path=")) {<br>
+               } else if (starts_with(argv[i], "--scan-tree=") ||<br>
+                          starts_with(argv[i], "--scan-path=")) {<br>
                        /*<br>
                         * HACK: The global snapshot bit mask defines the set<br>
                         * of allowed snapshot formats, but the config file<br>
diff --git a/git b/git<br>
index 0bc85ab..e156455 160000<br>
--- a/git<br>
+++ b/git<br>
@@ -1 +1 @@<br>
-Subproject commit 0bc85abb7aa9b24b093253018801a0fb43d01122<br>
+Subproject commit e156455ea49124c140a67623f22a393db62d5d98<br>
diff --git a/parsing.c b/parsing.c<br>
index 5b4b1f4..073f46f 100644<br>
--- a/parsing.c<br>
+++ b/parsing.c<br>
@@ -147,25 +147,25 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)<br>
        if (p == NULL)<br>
                return ret;<br>
<br>
-       if (prefixcmp(p, "tree "))<br>
+       if (!starts_with(p, "tree "))<br>
                die("Bad commit: %s", sha1_to_hex(commit->object.sha1));<br>
        else<br>
                p += 46; // "tree " + hex[40] + "\n"<br>
<br>
-       while (!prefixcmp(p, "parent "))<br>
+       while (starts_with(p, "parent "))<br>
                p += 48; // "parent " + hex[40] + "\n"<br>
<br>
-       if (p && !prefixcmp(p, "author ")) {<br>
+       if (p && starts_with(p, "author ")) {<br>
                p = parse_user(p + 7, &ret->author, &ret->author_email,<br>
                        &ret->author_date);<br>
        }<br>
<br>
-       if (p && !prefixcmp(p, "committer ")) {<br>
+       if (p && starts_with(p, "committer ")) {<br>
                p = parse_user(p + 10, &ret->committer, &ret->committer_email,<br>
                        &ret->committer_date);<br>
        }<br>
<br>
-       if (p && !prefixcmp(p, "encoding ")) {<br>
+       if (p && starts_with(p, "encoding ")) {<br>
                p += 9;<br>
                t = strchr(p, '\n');<br>
                if (t) {<br>
@@ -244,7 +244,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)<br>
                if (*p == '\n')<br>
                        break;<br>
<br>
-               if (!prefixcmp(p, "tagger ")) {<br>
+               if (starts_with(p, "tagger ")) {<br>
                        p = parse_user(p + 7, &ret->tagger, &ret->tagger_email,<br>
                                &ret->tagger_date);<br>
                } else {<br>
diff --git a/scan-tree.c b/scan-tree.c<br>
index 49de658..87fa0c7 100644<br>
--- a/scan-tree.c<br>
+++ b/scan-tree.c<br>
@@ -61,7 +61,7 @@ static int gitconfig_config(const char *key, const char *value, void *cb)<br>
                config_fn(repo, "desc", value);<br>
        else if (!strcmp(key, "gitweb.category"))<br>
                config_fn(repo, "section", value);<br>
-       else if (!prefixcmp(key, "cgit."))<br>
+       else if (starts_with(key, "cgit."))<br>
                config_fn(repo, key + 5, value);<br>
<br>
        return 0;<br>
@@ -105,7 +105,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)<br>
                return;<br>
        strbuf_setlen(path, pathlen);<br>
<br>
-       if (prefixcmp(path->buf, base))<br>
+       if (!starts_with(path->buf, base))<br>
                strbuf_addbuf(&rel, path);<br>
        else<br>
                strbuf_addstr(&rel, path->buf + strlen(base) + 1);<br>
@@ -115,6 +115,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)<br>
        else if (rel.len && rel.buf[rel.len - 1] == '/')<br>
                strbuf_setlen(&rel, rel.len - 1);<br>
<br>
+       fprintf(stderr, "add_repo(): %s\n", rel.buf);<br>
        repo = cgit_add_repo(rel.buf);<br>
        config_fn = fn;<br>
        if (ctx.cfg.enable_git_config) {<br>
@@ -161,7 +162,8 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)<br>
                        *slash = '\0';<br>
                        repo->section = xstrdup(rel.buf);<br>
                        *slash = '/';<br>
-                       if (!prefixcmp(repo->name, repo->section)) {<br>
+                       fprintf(stderr, "repo->name %s, repo->section %s\n", repo->name, repo->section);<br>
+                       if (starts_with(repo->name, repo->section)) {<br>
                                repo->name += strlen(repo->section);<br>
                                if (*repo->name == '/')<br>
                                        repo->name++;<br>
@@ -184,6 +186,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)<br>
        size_t pathlen = strlen(path);<br>
        struct stat st;<br>
<br>
+       fprintf(stderr, "scan_path(): %s\n", path);<br>
        if (!dir) {<br>
                fprintf(stderr, "Error opening directory %s: %s (%d)\n",<br>
                        path, strerror(errno), errno);<br>
@@ -192,6 +195,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)<br>
<br>
        strbuf_add(&pathbuf, path, strlen(path));<br>
        if (is_git_dir(pathbuf.buf)) {<br>
+               fprintf(stderr, "scan_path() is_git_dir: %s\n", path);<br>
                add_repo(base, &pathbuf, fn);<br>
                goto end;<br>
        }<br>
diff --git a/ui-clone.c b/ui-clone.c<br>
index d25553b..a4ffd6e 100644<br>
--- a/ui-clone.c<br>
+++ b/ui-clone.c<br>
@@ -63,7 +63,7 @@ static void send_file(char *path)<br>
        }<br>
        ctx.page.mimetype = "application/octet-stream";<br>
        ctx.page.filename = path;<br>
-       if (prefixcmp(ctx.repo->path, path))<br>
+       if (!starts_with(ctx.repo->path, path))<br>
                ctx.page.filename += strlen(ctx.repo->path) + 1;<br>
        cgit_print_http_headers();<br>
        html_include(path);<br>
diff --git a/ui-log.c b/ui-log.c<br>
index 499534c..2de8017 100644<br>
--- a/ui-log.c<br>
+++ b/ui-log.c<br>
@@ -63,21 +63,21 @@ void show_commit_decorations(struct commit *commit)<br>
        deco = lookup_decoration(&name_decoration, &commit->object);<br>
        html("<span class='decoration'>");<br>
        while (deco) {<br>
-               if (!prefixcmp(deco->name, "refs/heads/")) {<br>
+               if (starts_with(deco->name, "refs/heads/")) {<br>
                        strncpy(buf, deco->name + 11, sizeof(buf) - 1);<br>
                        cgit_log_link(buf, NULL, "branch-deco", buf, NULL,<br>
                                      ctx.qry.vpath, 0, NULL, NULL,<br>
                                      ctx.qry.showmsg);<br>
                }<br>
-               else if (!prefixcmp(deco->name, "tag: refs/tags/")) {<br>
+               else if (starts_with(deco->name, "tag: refs/tags/")) {<br>
                        strncpy(buf, deco->name + 15, sizeof(buf) - 1);<br>
                        cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);<br>
                }<br>
-               else if (!prefixcmp(deco->name, "refs/tags/")) {<br>
+               else if (starts_with(deco->name, "refs/tags/")) {<br>
                        strncpy(buf, deco->name + 10, sizeof(buf) - 1);<br>
                        cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);<br>
                }<br>
-               else if (!prefixcmp(deco->name, "refs/remotes/")) {<br>
+               else if (starts_with(deco->name, "refs/remotes/")) {<br>
                        if (!ctx.repo->enable_remote_branches)<br>
                                goto next;<br>
                        strncpy(buf, deco->name + 13, sizeof(buf) - 1);<br>
diff --git a/ui-refs.c b/ui-refs.c<br>
index 0da063f..7e58737 100644<br>
--- a/ui-refs.c<br>
+++ b/ui-refs.c<br>
@@ -101,7 +101,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)<br>
                return;<br>
<br>
        basename = cgit_repobasename(repo->url);<br>
-       if (prefixcmp(ref, basename) != 0) {<br>
+       if (!starts_with(ref, basename)) {<br>
                if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]))<br>
                        ref++;<br>
                if (isdigit(ref[0])) {<br>
@@ -239,9 +239,9 @@ void cgit_print_refs()<br>
<br>
        html("<table class='list nowrap'>");<br>
<br>
-       if (ctx.qry.path && !prefixcmp(ctx.qry.path, "heads"))<br>
+       if (ctx.qry.path && starts_with(ctx.qry.path, "heads"))<br>
                cgit_print_branches(0);<br>
-       else if (ctx.qry.path && !prefixcmp(ctx.qry.path, "tags"))<br>
+       else if (ctx.qry.path && starts_with(ctx.qry.path, "tags"))<br>
                cgit_print_tags(0);<br>
        else {<br>
                cgit_print_branches(0);<br>
diff --git a/ui-repolist.c b/ui-repolist.c<br>
index 477a949..c2bcce1 100644<br>
--- a/ui-repolist.c<br>
+++ b/ui-repolist.c<br>
@@ -99,7 +99,7 @@ static int is_in_url(struct cgit_repo *repo)<br>
 {<br>
        if (!ctx.qry.url)<br>
                return 1;<br>
-       if (repo->url && !prefixcmp(repo->url, ctx.qry.url))<br>
+       if (repo->url && starts_with(repo->url, ctx.qry.url))<br>
                return 1;<br>
        return 0;<br>
 }<br>
diff --git a/ui-shared.c b/ui-shared.c<br>
index 1ede2b0..9dde0a3 100644<br>
--- a/ui-shared.c<br>
+++ b/ui-shared.c<br>
@@ -128,7 +128,7 @@ const char *cgit_repobasename(const char *reponame)<br>
        /* strip trailing slashes */<br>
        while (p && rvbuf[p] == '/') rvbuf[p--] = 0;<br>
        /* strip trailing .git */<br>
-       if (p >= 3 && !prefixcmp(&rvbuf[p-3], ".git")) {<br>
+       if (p >= 3 && starts_with(&rvbuf[p-3], ".git")) {<br>
                p -= 3; rvbuf[p--] = 0;<br>
        }<br>
        /* strip more trailing slashes if any */<br>
diff --git a/ui-snapshot.c b/ui-snapshot.c<br>
index 3107b05..ea77eb4 100644<br>
--- a/ui-snapshot.c<br>
+++ b/ui-snapshot.c<br>
@@ -99,7 +99,7 @@ static const struct cgit_snapshot_format *get_format(const char *filename)<br>
        const struct cgit_snapshot_format *fmt;<br>
<br>
        for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {<br>
-               if (!suffixcmp(filename, fmt->suffix))<br>
+               if (ends_with(filename, fmt->suffix))<br>
                        return fmt;<br>
        }<br>
        return NULL;<br>
@@ -151,7 +151,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename,<br>
                goto out;<br>
<br>
        reponame = cgit_repobasename(url);<br>
-       if (prefixcmp(snapshot.buf, reponame) == 0) {<br>
+       if (starts_with(snapshot.buf, reponame)) {<br>
                const char *new_start = snapshot.buf;<br>
                new_start += strlen(reponame);<br>
                while (new_start && (*new_start == '-' || *new_start == '_'))<br>
diff --git a/ui-summary.c b/ui-summary.c<br>
index df99ce1..3728c3e 100644<br>
--- a/ui-summary.c<br>
+++ b/ui-summary.c<br>
@@ -116,7 +116,7 @@ static char* append_readme_path(const char *filename, const char *ref, const cha<br>
        if (!ref) {<br>
                resolved_base = realpath(base_dir, NULL);<br>
                resolved_full = realpath(full_path, NULL);<br>
-               if (!resolved_base || !resolved_full || prefixcmp(resolved_full, resolved_base)) {<br>
+               if (!resolved_base || !resolved_full || !starts_with(resolved_full, resolved_base)) {<br>
                        free(full_path);<br>
                        full_path = NULL;<br>
                }<br>
--<br>
1.9.3<br>
<br>
_______________________________________________<br>
CGit mailing list<br>
<a href="mailto:CGit@lists.zx2c4.com">CGit@lists.zx2c4.com</a><br>
<a href="http://lists.zx2c4.com/mailman/listinfo/cgit" target="_blank">http://lists.zx2c4.com/mailman/listinfo/cgit</a><br>
</blockquote></div>