]> git.cameronkatri.com Git - cgit.git/blobdiff - parsing.c
ui-log: ignore unhandled arguments
[cgit.git] / parsing.c
index 658621d8e76b74336eb8827b3354d59ec9d35320..073f46fc708ee4fc5d251bd25f6a6e48f20344ae 100644 (file)
--- a/parsing.c
+++ b/parsing.c
@@ -1,6 +1,6 @@
-/* config.c: parsing of config files
+/* parsing.c: parsing of config files
  *
- * Copyright (C) 2006 Lars Hjemli
+ * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
  *
  * Licensed under GNU General Public License v2
  *   (see COPYING for full license text)
@@ -17,7 +17,8 @@
  */
 void cgit_parse_url(const char *url)
 {
-       char *cmd, *p;
+       char *c, *cmd, *p;
+       struct cgit_repo *repo;
 
        ctx.repo = NULL;
        if (!url || url[0] == '\0')
@@ -29,16 +30,20 @@ void cgit_parse_url(const char *url)
                return;
        }
 
-       cmd = strchr(url, '/');
-       while (!ctx.repo && cmd) {
-               cmd[0] = '\0';
-               ctx.repo = cgit_get_repoinfo(url);
-               if (ctx.repo == NULL) {
-                       cmd[0] = '/';
-                       cmd = strchr(cmd + 1, '/');
-                       continue;
+       cmd = NULL;
+       c = strchr(url, '/');
+       while (c) {
+               c[0] = '\0';
+               repo = cgit_get_repoinfo(url);
+               if (repo) {
+                       ctx.repo = repo;
+                       cmd = c;
                }
+               c[0] = '/';
+               c = strchr(c + 1, '/');
+       }
 
+       if (ctx.repo) {
                ctx.qry.repo = ctx.repo->url;
                p = strchr(cmd + 1, '/');
                if (p) {
@@ -142,25 +147,25 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
        if (p == NULL)
                return ret;
 
-       if (strncmp(p, "tree ", 5))
+       if (!starts_with(p, "tree "))
                die("Bad commit: %s", sha1_to_hex(commit->object.sha1));
        else
                p += 46; // "tree " + hex[40] + "\n"
 
-       while (!strncmp(p, "parent ", 7))
+       while (starts_with(p, "parent "))
                p += 48; // "parent " + hex[40] + "\n"
 
-       if (p && !strncmp(p, "author ", 7)) {
+       if (p && starts_with(p, "author ")) {
                p = parse_user(p + 7, &ret->author, &ret->author_email,
                        &ret->author_date);
        }
 
-       if (p && !strncmp(p, "committer ", 9)) {
-               p = parse_user(p + 9, &ret->committer, &ret->committer_email,
+       if (p && starts_with(p, "committer ")) {
+               p = parse_user(p + 10, &ret->committer, &ret->committer_email,
                        &ret->committer_date);
        }
 
-       if (p && !strncmp(p, "encoding ", 9)) {
+       if (p && starts_with(p, "encoding ")) {
                p += 9;
                t = strchr(p, '\n');
                if (t) {
@@ -239,7 +244,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)
                if (*p == '\n')
                        break;
 
-               if (!strncmp(p, "tagger ", 7)) {
+               if (starts_with(p, "tagger ")) {
                        p = parse_user(p + 7, &ret->tagger, &ret->tagger_email,
                                &ret->tagger_date);
                } else {