diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cgit.c | 26 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | parsing.c | 12 | ||||
-rw-r--r-- | scan-tree.c | 10 | ||||
-rw-r--r-- | ui-clone.c | 2 | ||||
-rw-r--r-- | ui-log.c | 8 | ||||
-rw-r--r-- | ui-refs.c | 6 | ||||
-rw-r--r-- | ui-repolist.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 2 | ||||
-rw-r--r-- | ui-snapshot.c | 4 | ||||
-rw-r--r-- | ui-summary.c | 2 |
12 files changed, 40 insertions, 36 deletions
@@ -14,7 +14,7 @@ htmldir = $(docdir) | |||
14 | pdfdir = $(docdir) | 14 | pdfdir = $(docdir) |
15 | mandir = $(prefix)/share/man | 15 | mandir = $(prefix)/share/man |
16 | SHA1_HEADER = <openssl/sha.h> | 16 | SHA1_HEADER = <openssl/sha.h> |
17 | GIT_VER = 1.9.2 | 17 | GIT_VER = 2.0.0 |
18 | GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz | 18 | GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz |
19 | INSTALL = install | 19 | INSTALL = install |
20 | COPYTREE = cp -r | 20 | COPYTREE = cp -r |
@@ -69,7 +69,7 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va | |||
69 | repo->max_stats = cgit_find_stats_period(value, NULL); | 69 | repo->max_stats = cgit_find_stats_period(value, NULL); |
70 | else if (!strcmp(name, "module-link")) | 70 | else if (!strcmp(name, "module-link")) |
71 | repo->module_link= xstrdup(value); | 71 | repo->module_link= xstrdup(value); |
72 | else if (!prefixcmp(name, "module-link.")) { | 72 | else if (starts_with(name, "module-link.")) { |
73 | item = string_list_append(&repo->submodules, xstrdup(name + 12)); | 73 | item = string_list_append(&repo->submodules, xstrdup(name + 12)); |
74 | item->util = xstrdup(value); | 74 | item->util = xstrdup(value); |
75 | } else if (!strcmp(name, "section")) | 75 | } else if (!strcmp(name, "section")) |
@@ -102,7 +102,7 @@ static void config_cb(const char *name, const char *value) | |||
102 | ctx.repo = cgit_add_repo(value); | 102 | ctx.repo = cgit_add_repo(value); |
103 | else if (ctx.repo && !strcmp(name, "repo.path")) | 103 | else if (ctx.repo && !strcmp(name, "repo.path")) |
104 | ctx.repo->path = trim_end(value, '/'); | 104 | ctx.repo->path = trim_end(value, '/'); |
105 | else if (ctx.repo && !prefixcmp(name, "repo.")) | 105 | else if (ctx.repo && starts_with(name, "repo.")) |
106 | repo_config(ctx.repo, name + 5, value); | 106 | repo_config(ctx.repo, name + 5, value); |
107 | else if (!strcmp(name, "readme") && value != NULL) | 107 | else if (!strcmp(name, "readme") && value != NULL) |
108 | string_list_append(&ctx.cfg.readme, xstrdup(value)); | 108 | string_list_append(&ctx.cfg.readme, xstrdup(value)); |
@@ -264,7 +264,7 @@ static void config_cb(const char *name, const char *value) | |||
264 | ctx.cfg.branch_sort = 1; | 264 | ctx.cfg.branch_sort = 1; |
265 | if (!strcmp(value, "name")) | 265 | if (!strcmp(value, "name")) |
266 | ctx.cfg.branch_sort = 0; | 266 | ctx.cfg.branch_sort = 0; |
267 | } else if (!prefixcmp(name, "mimetype.")) | 267 | } else if (starts_with(name, "mimetype.")) |
268 | add_mimetype(name + 9, value); | 268 | add_mimetype(name + 9, value); |
269 | else if (!strcmp(name, "include")) | 269 | else if (!strcmp(name, "include")) |
270 | parse_configfile(expand_macros(value), config_cb); | 270 | parse_configfile(expand_macros(value), config_cb); |
@@ -454,7 +454,7 @@ static char *guess_defbranch(void) | |||
454 | unsigned char sha1[20]; | 454 | unsigned char sha1[20]; |
455 | 455 | ||
456 | ref = resolve_ref_unsafe("HEAD", sha1, 0, NULL); | 456 | ref = resolve_ref_unsafe("HEAD", sha1, 0, NULL); |
457 | if (!ref || prefixcmp(ref, "refs/heads/")) | 457 | if (!ref || !starts_with(ref, "refs/heads/")) |
458 | return "master"; | 458 | return "master"; |
459 | return xstrdup(ref + 11); | 459 | return xstrdup(ref + 11); |
460 | } | 460 | } |
@@ -941,28 +941,28 @@ static void cgit_parse_args(int argc, const char **argv) | |||
941 | 941 | ||
942 | exit(0); | 942 | exit(0); |
943 | } | 943 | } |
944 | if (!prefixcmp(argv[i], "--cache=")) { | 944 | if (starts_with(argv[i], "--cache=")) { |
945 | ctx.cfg.cache_root = xstrdup(argv[i] + 8); | 945 | ctx.cfg.cache_root = xstrdup(argv[i] + 8); |
946 | } else if (!strcmp(argv[i], "--nocache")) { | 946 | } else if (!strcmp(argv[i], "--nocache")) { |
947 | ctx.cfg.nocache = 1; | 947 | ctx.cfg.nocache = 1; |
948 | } else if (!strcmp(argv[i], "--nohttp")) { | 948 | } else if (!strcmp(argv[i], "--nohttp")) { |
949 | ctx.env.no_http = "1"; | 949 | ctx.env.no_http = "1"; |
950 | } else if (!prefixcmp(argv[i], "--query=")) { | 950 | } else if (starts_with(argv[i], "--query=")) { |
951 | ctx.qry.raw = xstrdup(argv[i] + 8); | 951 | ctx.qry.raw = xstrdup(argv[i] + 8); |
952 | } else if (!prefixcmp(argv[i], "--repo=")) { | 952 | } else if (starts_with(argv[i], "--repo=")) { |
953 | ctx.qry.repo = xstrdup(argv[i] + 7); | 953 | ctx.qry.repo = xstrdup(argv[i] + 7); |
954 | } else if (!prefixcmp(argv[i], "--page=")) { | 954 | } else if (starts_with(argv[i], "--page=")) { |
955 | ctx.qry.page = xstrdup(argv[i] + 7); | 955 | ctx.qry.page = xstrdup(argv[i] + 7); |
956 | } else if (!prefixcmp(argv[i], "--head=")) { | 956 | } else if (starts_with(argv[i], "--head=")) { |
957 | ctx.qry.head = xstrdup(argv[i] + 7); | 957 | ctx.qry.head = xstrdup(argv[i] + 7); |
958 | ctx.qry.has_symref = 1; | 958 | ctx.qry.has_symref = 1; |
959 | } else if (!prefixcmp(argv[i], "--sha1=")) { | 959 | } else if (starts_with(argv[i], "--sha1=")) { |
960 | ctx.qry.sha1 = xstrdup(argv[i] + 7); | 960 | ctx.qry.sha1 = xstrdup(argv[i] + 7); |
961 | ctx.qry.has_sha1 = 1; | 961 | ctx.qry.has_sha1 = 1; |
962 | } else if (!prefixcmp(argv[i], "--ofs=")) { | 962 | } else if (starts_with(argv[i], "--ofs=")) { |
963 | ctx.qry.ofs = atoi(argv[i] + 6); | 963 | ctx.qry.ofs = atoi(argv[i] + 6); |
964 | } else if (!prefixcmp(argv[i], "--scan-tree=") || | 964 | } else if (starts_with(argv[i], "--scan-tree=") || |
965 | !prefixcmp(argv[i], "--scan-path=")) { | 965 | starts_with(argv[i], "--scan-path=")) { |
966 | /* | 966 | /* |
967 | * HACK: The global snapshot bit mask defines the set | 967 | * HACK: The global snapshot bit mask defines the set |
968 | * of allowed snapshot formats, but the config file | 968 | * of allowed snapshot formats, but the config file |
diff --git a/git b/git | |||
Subproject 0bc85abb7aa9b24b093253018801a0fb43d0112 | Subproject e156455ea49124c140a67623f22a393db62d5d9 | ||
@@ -147,25 +147,25 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) | |||
147 | if (p == NULL) | 147 | if (p == NULL) |
148 | return ret; | 148 | return ret; |
149 | 149 | ||
150 | if (prefixcmp(p, "tree ")) | 150 | if (!starts_with(p, "tree ")) |
151 | die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); | 151 | die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); |
152 | else | 152 | else |
153 | p += 46; // "tree " + hex[40] + "\n" | 153 | p += 46; // "tree " + hex[40] + "\n" |
154 | 154 | ||
155 | while (!prefixcmp(p, "parent ")) | 155 | while (starts_with(p, "parent ")) |
156 | p += 48; // "parent " + hex[40] + "\n" | 156 | p += 48; // "parent " + hex[40] + "\n" |
157 | 157 | ||
158 | if (p && !prefixcmp(p, "author ")) { | 158 | if (p && starts_with(p, "author ")) { |
159 | p = parse_user(p + 7, &ret->author, &ret->author_email, | 159 | p = parse_user(p + 7, &ret->author, &ret->author_email, |
160 | &ret->author_date); | 160 | &ret->author_date); |
161 | } | 161 | } |
162 | 162 | ||
163 | if (p && !prefixcmp(p, "committer ")) { | 163 | if (p && starts_with(p, "committer ")) { |
164 | p = parse_user(p + 10, &ret->committer, &ret->committer_email, | 164 | p = parse_user(p + 10, &ret->committer, &ret->committer_email, |
165 | &ret->committer_date); | 165 | &ret->committer_date); |
166 | } | 166 | } |
167 | 167 | ||
168 | if (p && !prefixcmp(p, "encoding ")) { | 168 | if (p && starts_with(p, "encoding ")) { |
169 | p += 9; | 169 | p += 9; |
170 | t = strchr(p, '\n'); | 170 | t = strchr(p, '\n'); |
171 | if (t) { | 171 | if (t) { |
@@ -244,7 +244,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) | |||
244 | if (*p == '\n') | 244 | if (*p == '\n') |
245 | break; | 245 | break; |
246 | 246 | ||
247 | if (!prefixcmp(p, "tagger ")) { | 247 | if (starts_with(p, "tagger ")) { |
248 | p = parse_user(p + 7, &ret->tagger, &ret->tagger_email, | 248 | p = parse_user(p + 7, &ret->tagger, &ret->tagger_email, |
249 | &ret->tagger_date); | 249 | &ret->tagger_date); |
250 | } else { | 250 | } 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) | |||
61 | config_fn(repo, "desc", value); | 61 | config_fn(repo, "desc", value); |
62 | else if (!strcmp(key, "gitweb.category")) | 62 | else if (!strcmp(key, "gitweb.category")) |
63 | config_fn(repo, "section", value); | 63 | config_fn(repo, "section", value); |
64 | else if (!prefixcmp(key, "cgit.")) | 64 | else if (starts_with(key, "cgit.")) |
65 | config_fn(repo, key + 5, value); | 65 | config_fn(repo, key + 5, value); |
66 | 66 | ||
67 | return 0; | 67 | return 0; |
@@ -105,7 +105,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) | |||
105 | return; | 105 | return; |
106 | strbuf_setlen(path, pathlen); | 106 | strbuf_setlen(path, pathlen); |
107 | 107 | ||
108 | if (prefixcmp(path->buf, base)) | 108 | if (!starts_with(path->buf, base)) |
109 | strbuf_addbuf(&rel, path); | 109 | strbuf_addbuf(&rel, path); |
110 | else | 110 | else |
111 | strbuf_addstr(&rel, path->buf + strlen(base) + 1); | 111 | 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) | |||
115 | else if (rel.len && rel.buf[rel.len - 1] == '/') | 115 | else if (rel.len && rel.buf[rel.len - 1] == '/') |
116 | strbuf_setlen(&rel, rel.len - 1); | 116 | strbuf_setlen(&rel, rel.len - 1); |
117 | 117 | ||
118 | fprintf(stderr, "add_repo(): %s\n", rel.buf); | ||
118 | repo = cgit_add_repo(rel.buf); | 119 | repo = cgit_add_repo(rel.buf); |
119 | config_fn = fn; | 120 | config_fn = fn; |
120 | if (ctx.cfg.enable_git_config) { | 121 | if (ctx.cfg.enable_git_config) { |
@@ -161,7 +162,8 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn) | |||
161 | *slash = '\0'; | 162 | *slash = '\0'; |
162 | repo->section = xstrdup(rel.buf); | 163 | repo->section = xstrdup(rel.buf); |
163 | *slash = '/'; | 164 | *slash = '/'; |
164 | if (!prefixcmp(repo->name, repo->section)) { | 165 | fprintf(stderr, "repo->name %s, repo->section %s\n", repo->name, repo->section); |
166 | if (starts_with(repo->name, repo->section)) { | ||
165 | repo->name += strlen(repo->section); | 167 | repo->name += strlen(repo->section); |
166 | if (*repo->name == '/') | 168 | if (*repo->name == '/') |
167 | repo->name++; | 169 | repo->name++; |
@@ -184,6 +186,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn) | |||
184 | size_t pathlen = strlen(path); | 186 | size_t pathlen = strlen(path); |
185 | struct stat st; | 187 | struct stat st; |
186 | 188 | ||
189 | fprintf(stderr, "scan_path(): %s\n", path); | ||
187 | if (!dir) { | 190 | if (!dir) { |
188 | fprintf(stderr, "Error opening directory %s: %s (%d)\n", | 191 | fprintf(stderr, "Error opening directory %s: %s (%d)\n", |
189 | path, strerror(errno), errno); | 192 | path, strerror(errno), errno); |
@@ -192,6 +195,7 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn) | |||
192 | 195 | ||
193 | strbuf_add(&pathbuf, path, strlen(path)); | 196 | strbuf_add(&pathbuf, path, strlen(path)); |
194 | if (is_git_dir(pathbuf.buf)) { | 197 | if (is_git_dir(pathbuf.buf)) { |
198 | fprintf(stderr, "scan_path() is_git_dir: %s\n", path); | ||
195 | add_repo(base, &pathbuf, fn); | 199 | add_repo(base, &pathbuf, fn); |
196 | goto end; | 200 | goto end; |
197 | } | 201 | } |
@@ -63,7 +63,7 @@ static void send_file(char *path) | |||
63 | } | 63 | } |
64 | ctx.page.mimetype = "application/octet-stream"; | 64 | ctx.page.mimetype = "application/octet-stream"; |
65 | ctx.page.filename = path; | 65 | ctx.page.filename = path; |
66 | if (prefixcmp(ctx.repo->path, path)) | 66 | if (!starts_with(ctx.repo->path, path)) |
67 | ctx.page.filename += strlen(ctx.repo->path) + 1; | 67 | ctx.page.filename += strlen(ctx.repo->path) + 1; |
68 | cgit_print_http_headers(); | 68 | cgit_print_http_headers(); |
69 | html_include(path); | 69 | html_include(path); |
@@ -63,21 +63,21 @@ void show_commit_decorations(struct commit *commit) | |||
63 | deco = lookup_decoration(&name_decoration, &commit->object); | 63 | deco = lookup_decoration(&name_decoration, &commit->object); |
64 | html("<span class='decoration'>"); | 64 | html("<span class='decoration'>"); |
65 | while (deco) { | 65 | while (deco) { |
66 | if (!prefixcmp(deco->name, "refs/heads/")) { | 66 | if (starts_with(deco->name, "refs/heads/")) { |
67 | strncpy(buf, deco->name + 11, sizeof(buf) - 1); | 67 | strncpy(buf, deco->name + 11, sizeof(buf) - 1); |
68 | cgit_log_link(buf, NULL, "branch-deco", buf, NULL, | 68 | cgit_log_link(buf, NULL, "branch-deco", buf, NULL, |
69 | ctx.qry.vpath, 0, NULL, NULL, | 69 | ctx.qry.vpath, 0, NULL, NULL, |
70 | ctx.qry.showmsg); | 70 | ctx.qry.showmsg); |
71 | } | 71 | } |
72 | else if (!prefixcmp(deco->name, "tag: refs/tags/")) { | 72 | else if (starts_with(deco->name, "tag: refs/tags/")) { |
73 | strncpy(buf, deco->name + 15, sizeof(buf) - 1); | 73 | strncpy(buf, deco->name + 15, sizeof(buf) - 1); |
74 | cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); | 74 | cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); |
75 | } | 75 | } |
76 | else if (!prefixcmp(deco->name, "refs/tags/")) { | 76 | else if (starts_with(deco->name, "refs/tags/")) { |
77 | strncpy(buf, deco->name + 10, sizeof(buf) - 1); | 77 | strncpy(buf, deco->name + 10, sizeof(buf) - 1); |
78 | cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); | 78 | cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); |
79 | } | 79 | } |
80 | else if (!prefixcmp(deco->name, "refs/remotes/")) { | 80 | else if (starts_with(deco->name, "refs/remotes/")) { |
81 | if (!ctx.repo->enable_remote_branches) | 81 | if (!ctx.repo->enable_remote_branches) |
82 | goto next; | 82 | goto next; |
83 | strncpy(buf, deco->name + 13, sizeof(buf) - 1); | 83 | strncpy(buf, deco->name + 13, sizeof(buf) - 1); |
@@ -101,7 +101,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) | |||
101 | return; | 101 | return; |
102 | 102 | ||
103 | basename = cgit_repobasename(repo->url); | 103 | basename = cgit_repobasename(repo->url); |
104 | if (prefixcmp(ref, basename) != 0) { | 104 | if (!starts_with(ref, basename)) { |
105 | if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1])) | 105 | if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1])) |
106 | ref++; | 106 | ref++; |
107 | if (isdigit(ref[0])) { | 107 | if (isdigit(ref[0])) { |
@@ -239,9 +239,9 @@ void cgit_print_refs() | |||
239 | 239 | ||
240 | html("<table class='list nowrap'>"); | 240 | html("<table class='list nowrap'>"); |
241 | 241 | ||
242 | if (ctx.qry.path && !prefixcmp(ctx.qry.path, "heads")) | 242 | if (ctx.qry.path && starts_with(ctx.qry.path, "heads")) |
243 | cgit_print_branches(0); | 243 | cgit_print_branches(0); |
244 | else if (ctx.qry.path && !prefixcmp(ctx.qry.path, "tags")) | 244 | else if (ctx.qry.path && starts_with(ctx.qry.path, "tags")) |
245 | cgit_print_tags(0); | 245 | cgit_print_tags(0); |
246 | else { | 246 | else { |
247 | cgit_print_branches(0); | 247 | 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) | |||
99 | { | 99 | { |
100 | if (!ctx.qry.url) | 100 | if (!ctx.qry.url) |
101 | return 1; | 101 | return 1; |
102 | if (repo->url && !prefixcmp(repo->url, ctx.qry.url)) | 102 | if (repo->url && starts_with(repo->url, ctx.qry.url)) |
103 | return 1; | 103 | return 1; |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
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) | |||
128 | /* strip trailing slashes */ | 128 | /* strip trailing slashes */ |
129 | while (p && rvbuf[p] == '/') rvbuf[p--] = 0; | 129 | while (p && rvbuf[p] == '/') rvbuf[p--] = 0; |
130 | /* strip trailing .git */ | 130 | /* strip trailing .git */ |
131 | if (p >= 3 && !prefixcmp(&rvbuf[p-3], ".git")) { | 131 | if (p >= 3 && starts_with(&rvbuf[p-3], ".git")) { |
132 | p -= 3; rvbuf[p--] = 0; | 132 | p -= 3; rvbuf[p--] = 0; |
133 | } | 133 | } |
134 | /* strip more trailing slashes if any */ | 134 | /* 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) | |||
99 | const struct cgit_snapshot_format *fmt; | 99 | const struct cgit_snapshot_format *fmt; |
100 | 100 | ||
101 | for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) { | 101 | for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) { |
102 | if (!suffixcmp(filename, fmt->suffix)) | 102 | if (ends_with(filename, fmt->suffix)) |
103 | return fmt; | 103 | return fmt; |
104 | } | 104 | } |
105 | return NULL; | 105 | return NULL; |
@@ -151,7 +151,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename, | |||
151 | goto out; | 151 | goto out; |
152 | 152 | ||
153 | reponame = cgit_repobasename(url); | 153 | reponame = cgit_repobasename(url); |
154 | if (prefixcmp(snapshot.buf, reponame) == 0) { | 154 | if (starts_with(snapshot.buf, reponame)) { |
155 | const char *new_start = snapshot.buf; | 155 | const char *new_start = snapshot.buf; |
156 | new_start += strlen(reponame); | 156 | new_start += strlen(reponame); |
157 | while (new_start && (*new_start == '-' || *new_start == '_')) | 157 | 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 | |||
116 | if (!ref) { | 116 | if (!ref) { |
117 | resolved_base = realpath(base_dir, NULL); | 117 | resolved_base = realpath(base_dir, NULL); |
118 | resolved_full = realpath(full_path, NULL); | 118 | resolved_full = realpath(full_path, NULL); |
119 | if (!resolved_base || !resolved_full || prefixcmp(resolved_full, resolved_base)) { | 119 | if (!resolved_base || !resolved_full || !starts_with(resolved_full, resolved_base)) { |
120 | free(full_path); | 120 | free(full_path); |
121 | full_path = NULL; | 121 | full_path = NULL; |
122 | } | 122 | } |