[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgit
Subject:    Re: [PATCH 1/1] git: update for git 2.0
From:       "Jason A. Donenfeld" <Jason () zx2c4 ! com>
Date:       2014-06-29 16:24:24
Message-ID: CAHmME9qcrXiNPpLNB7WZX=wuEs2RnKW7oJBGh5W9f2w-wuQ6Ew () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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?

--
Sent from my telephone.
On May 29, 2014 5:53 PM, "Christian Hesse" <mail@eworm.de> wrote:

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

[Attachment #5 (text/html)]

<p dir="ltr">You&#39;ve added a bunch of fprintf(stderr, &quot;debugging \
blah...&quot;) 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, &quot;Christian Hesse&quot; &lt;<a \
href="mailto:mail@eworm.de">mail@eworm.de</a>&gt; 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 = &lt;openssl/sha.h&gt;<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-&gt;max_stats = cgit_find_stats_period(value, NULL);<br>
            else if (!strcmp(name, &quot;module-link&quot;))<br>
                        repo-&gt;module_link= xstrdup(value);<br>
-          else if (!prefixcmp(name, &quot;module-link.&quot;)) {<br>
+          else if (starts_with(name, &quot;module-link.&quot;)) {<br>
                        item = string_list_append(&amp;repo-&gt;submodules, \
xstrdup(name + 12));<br>  item-&gt;util = xstrdup(value);<br>
            } else if (!strcmp(name, &quot;section&quot;))<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 &amp;&amp; !strcmp(name, &quot;repo.path&quot;))<br>
                        ctx.repo-&gt;path = trim_end(value, &#39;/&#39;);<br>
-          else if (ctx.repo &amp;&amp; !prefixcmp(name, &quot;repo.&quot;))<br>
+          else if (ctx.repo &amp;&amp; starts_with(name, &quot;repo.&quot;))<br>
                        repo_config(ctx.repo, name + 5, value);<br>
            else if (!strcmp(name, &quot;readme&quot;) &amp;&amp; value != NULL)<br>
                        string_list_append(&amp;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, &quot;name&quot;))<br>
                                    ctx.cfg.branch_sort = 0;<br>
-          } else if (!prefixcmp(name, &quot;mimetype.&quot;))<br>
+          } else if (starts_with(name, &quot;mimetype.&quot;))<br>
                        add_mimetype(name + 9, value);<br>
            else if (!strcmp(name, &quot;include&quot;))<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(&quot;HEAD&quot;, sha1, 0, NULL);<br>
-          if (!ref || prefixcmp(ref, &quot;refs/heads/&quot;))<br>
+          if (!ref || !starts_with(ref, &quot;refs/heads/&quot;))<br>
                        return &quot;master&quot;;<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], &quot;--cache=&quot;)) {<br>
+                      if (starts_with(argv[i], &quot;--cache=&quot;)) {<br>
                                    ctx.cfg.cache_root = xstrdup(argv[i] + 8);<br>
                        } else if (!strcmp(argv[i], &quot;--nocache&quot;)) {<br>
                                    ctx.cfg.nocache = 1;<br>
                        } else if (!strcmp(argv[i], &quot;--nohttp&quot;)) {<br>
                                    ctx.env.no_http = &quot;1&quot;;<br>
-                      } else if (!prefixcmp(argv[i], &quot;--query=&quot;)) {<br>
+                      } else if (starts_with(argv[i], &quot;--query=&quot;)) {<br>
                                    ctx.qry.raw = xstrdup(argv[i] + 8);<br>
-                      } else if (!prefixcmp(argv[i], &quot;--repo=&quot;)) {<br>
+                      } else if (starts_with(argv[i], &quot;--repo=&quot;)) {<br>
                                    ctx.qry.repo = xstrdup(argv[i] + 7);<br>
-                      } else if (!prefixcmp(argv[i], &quot;--page=&quot;)) {<br>
+                      } else if (starts_with(argv[i], &quot;--page=&quot;)) {<br>
                                    ctx.qry.page = xstrdup(argv[i] + 7);<br>
-                      } else if (!prefixcmp(argv[i], &quot;--head=&quot;)) {<br>
+                      } else if (starts_with(argv[i], &quot;--head=&quot;)) {<br>
                                    ctx.qry.head = xstrdup(argv[i] + 7);<br>
                                    ctx.qry.has_symref = 1;<br>
-                      } else if (!prefixcmp(argv[i], &quot;--sha1=&quot;)) {<br>
+                      } else if (starts_with(argv[i], &quot;--sha1=&quot;)) {<br>
                                    ctx.qry.sha1 = xstrdup(argv[i] + 7);<br>
                                    ctx.qry.has_sha1 = 1;<br>
-                      } else if (!prefixcmp(argv[i], &quot;--ofs=&quot;)) {<br>
+                      } else if (starts_with(argv[i], &quot;--ofs=&quot;)) {<br>
                                    ctx.qry.ofs = atoi(argv[i] + 6);<br>
-                      } else if (!prefixcmp(argv[i], &quot;--scan-tree=&quot;) \
                ||<br>
-                                       !prefixcmp(argv[i], \
&quot;--scan-path=&quot;)) {<br> +                      } else if \
(starts_with(argv[i], &quot;--scan-tree=&quot;) ||<br> +                              \
starts_with(argv[i], &quot;--scan-path=&quot;)) {<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, &quot;tree &quot;))<br>
+          if (!starts_with(p, &quot;tree &quot;))<br>
                        die(&quot;Bad commit: %s&quot;, \
sha1_to_hex(commit-&gt;object.sha1));<br>  else<br>
                        p += 46; // &quot;tree &quot; + hex[40] + &quot;\n&quot;<br>
<br>
-          while (!prefixcmp(p, &quot;parent &quot;))<br>
+          while (starts_with(p, &quot;parent &quot;))<br>
                        p += 48; // &quot;parent &quot; + hex[40] + \
&quot;\n&quot;<br> <br>
-          if (p &amp;&amp; !prefixcmp(p, &quot;author &quot;)) {<br>
+          if (p &amp;&amp; starts_with(p, &quot;author &quot;)) {<br>
                        p = parse_user(p + 7, &amp;ret-&gt;author, \
&amp;ret-&gt;author_email,<br>  &amp;ret-&gt;author_date);<br>
            }<br>
<br>
-          if (p &amp;&amp; !prefixcmp(p, &quot;committer &quot;)) {<br>
+          if (p &amp;&amp; starts_with(p, &quot;committer &quot;)) {<br>
                        p = parse_user(p + 10, &amp;ret-&gt;committer, \
&amp;ret-&gt;committer_email,<br>  &amp;ret-&gt;committer_date);<br>
            }<br>
<br>
-          if (p &amp;&amp; !prefixcmp(p, &quot;encoding &quot;)) {<br>
+          if (p &amp;&amp; starts_with(p, &quot;encoding &quot;)) {<br>
                        p += 9;<br>
                        t = strchr(p, &#39;\n&#39;);<br>
                        if (t) {<br>
@@ -244,7 +244,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)<br>
                        if (*p == &#39;\n&#39;)<br>
                                    break;<br>
<br>
-                      if (!prefixcmp(p, &quot;tagger &quot;)) {<br>
+                      if (starts_with(p, &quot;tagger &quot;)) {<br>
                                    p = parse_user(p + 7, &amp;ret-&gt;tagger, \
                &amp;ret-&gt;tagger_email,<br>
                                                &amp;ret-&gt;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, &quot;desc&quot;, value);<br>
            else if (!strcmp(key, &quot;gitweb.category&quot;))<br>
                        config_fn(repo, &quot;section&quot;, value);<br>
-          else if (!prefixcmp(key, &quot;cgit.&quot;))<br>
+          else if (starts_with(key, &quot;cgit.&quot;))<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-&gt;buf, base))<br>
+          if (!starts_with(path-&gt;buf, base))<br>
                        strbuf_addbuf(&amp;rel, path);<br>
            else<br>
                        strbuf_addstr(&amp;rel, path-&gt;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 &amp;&amp; rel.buf[rel.len - 1] == &#39;/&#39;)<br>
                        strbuf_setlen(&amp;rel, rel.len - 1);<br>
<br>
+          fprintf(stderr, &quot;add_repo(): %s\n&quot;, 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 = &#39;\0&#39;;<br>
                                    repo-&gt;section = xstrdup(rel.buf);<br>
                                    *slash = &#39;/&#39;;<br>
-                                  if (!prefixcmp(repo-&gt;name, repo-&gt;section)) \
{<br> +                                  fprintf(stderr, &quot;repo-&gt;name %s, \
repo-&gt;section %s\n&quot;, repo-&gt;name, repo-&gt;section);<br> +                  \
                if (starts_with(repo-&gt;name, repo-&gt;section)) {<br>
                                                repo-&gt;name += \
                strlen(repo-&gt;section);<br>
                                                if (*repo-&gt;name == \
                &#39;/&#39;)<br>
                                                            repo-&gt;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, &quot;scan_path(): %s\n&quot;, path);<br>
            if (!dir) {<br>
                        fprintf(stderr, &quot;Error opening directory %s: %s \
(%d)\n&quot;,<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(&amp;pathbuf, path, strlen(path));<br>
            if (is_git_dir(pathbuf.buf)) {<br>
+                      fprintf(stderr, &quot;scan_path() is_git_dir: %s\n&quot;, \
path);<br>  add_repo(base, &amp;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 = &quot;application/octet-stream&quot;;<br>
            ctx.page.filename = path;<br>
-          if (prefixcmp(ctx.repo-&gt;path, path))<br>
+          if (!starts_with(ctx.repo-&gt;path, path))<br>
                        ctx.page.filename += strlen(ctx.repo-&gt;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(&amp;name_decoration, \
&amp;commit-&gt;object);<br>  html(&quot;&lt;span \
class=&#39;decoration&#39;&gt;&quot;);<br>  while (deco) {<br>
-                      if (!prefixcmp(deco-&gt;name, &quot;refs/heads/&quot;)) {<br>
+                      if (starts_with(deco-&gt;name, &quot;refs/heads/&quot;)) {<br>
                                    strncpy(buf, deco-&gt;name + 11, sizeof(buf) - \
                1);<br>
                                    cgit_log_link(buf, NULL, &quot;branch-deco&quot;, \
                buf, NULL,<br>
                                                         ctx.qry.vpath, 0, NULL, \
                NULL,<br>
                                                         ctx.qry.showmsg);<br>
                        }<br>
-                      else if (!prefixcmp(deco-&gt;name, &quot;tag: \
refs/tags/&quot;)) {<br> +                      else if (starts_with(deco-&gt;name, \
                &quot;tag: refs/tags/&quot;)) {<br>
                                    strncpy(buf, deco-&gt;name + 15, sizeof(buf) - \
                1);<br>
                                    cgit_tag_link(buf, NULL, &quot;tag-deco&quot;, \
ctx.qry.head, buf);<br>  }<br>
-                      else if (!prefixcmp(deco-&gt;name, &quot;refs/tags/&quot;)) \
{<br> +                      else if (starts_with(deco-&gt;name, \
                &quot;refs/tags/&quot;)) {<br>
                                    strncpy(buf, deco-&gt;name + 10, sizeof(buf) - \
                1);<br>
                                    cgit_tag_link(buf, NULL, &quot;tag-deco&quot;, \
ctx.qry.head, buf);<br>  }<br>
-                      else if (!prefixcmp(deco-&gt;name, &quot;refs/remotes/&quot;)) \
{<br> +                      else if (starts_with(deco-&gt;name, \
                &quot;refs/remotes/&quot;)) {<br>
                                    if (!ctx.repo-&gt;enable_remote_branches)<br>
                                                goto next;<br>
                                    strncpy(buf, deco-&gt;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-&gt;url);<br>
-          if (prefixcmp(ref, basename) != 0) {<br>
+          if (!starts_with(ref, basename)) {<br>
                        if ((ref[0] == &#39;v&#39; || ref[0] == &#39;V&#39;) \
&amp;&amp; isdigit(ref[1]))<br>  ref++;<br>
                        if (isdigit(ref[0])) {<br>
@@ -239,9 +239,9 @@ void cgit_print_refs()<br>
<br>
            html(&quot;&lt;table class=&#39;list nowrap&#39;&gt;&quot;);<br>
<br>
-          if (ctx.qry.path &amp;&amp; !prefixcmp(ctx.qry.path, \
&quot;heads&quot;))<br> +          if (ctx.qry.path &amp;&amp; \
starts_with(ctx.qry.path, &quot;heads&quot;))<br>  cgit_print_branches(0);<br>
-          else if (ctx.qry.path &amp;&amp; !prefixcmp(ctx.qry.path, \
&quot;tags&quot;))<br> +          else if (ctx.qry.path &amp;&amp; \
starts_with(ctx.qry.path, &quot;tags&quot;))<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-&gt;url &amp;&amp; !prefixcmp(repo-&gt;url, ctx.qry.url))<br>
+          if (repo-&gt;url &amp;&amp; starts_with(repo-&gt;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 &amp;&amp; rvbuf[p] == &#39;/&#39;) rvbuf[p--] = 0;<br>
            /* strip trailing .git */<br>
-          if (p &gt;= 3 &amp;&amp; !prefixcmp(&amp;rvbuf[p-3], &quot;.git&quot;)) \
{<br> +          if (p &gt;= 3 &amp;&amp; starts_with(&amp;rvbuf[p-3], \
&quot;.git&quot;)) {<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-&gt;suffix; fmt++) {<br>
-                      if (!suffixcmp(filename, fmt-&gt;suffix))<br>
+                      if (ends_with(filename, fmt-&gt;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 &amp;&amp; (*new_start == &#39;-&#39; || \
                *new_start == &#39;_&#39;))<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>



_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic