git: update for git 2.0

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.
upstream
Christian Hesse 11 years ago committed by Jason A. Donenfeld
parent b431282c91
commit 79c985e13c
  1. 2
      Makefile
  2. 26
      cgit.c
  3. 2
      git
  4. 12
      parsing.c
  5. 10
      scan-tree.c
  6. 2
      ui-clone.c
  7. 8
      ui-log.c
  8. 6
      ui-refs.c
  9. 2
      ui-repolist.c
  10. 2
      ui-shared.c
  11. 4
      ui-snapshot.c
  12. 2
      ui-summary.c

@ -14,7 +14,7 @@ htmldir = $(docdir)
pdfdir = $(docdir) pdfdir = $(docdir)
mandir = $(prefix)/share/man mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h> 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 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
INSTALL = install INSTALL = install
COPYTREE = cp -r COPYTREE = cp -r

@ -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); repo->max_stats = cgit_find_stats_period(value, NULL);
else if (!strcmp(name, "module-link")) else if (!strcmp(name, "module-link"))
repo->module_link= xstrdup(value); 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 = string_list_append(&repo->submodules, xstrdup(name + 12));
item->util = xstrdup(value); item->util = xstrdup(value);
} else if (!strcmp(name, "section")) } 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); ctx.repo = cgit_add_repo(value);
else if (ctx.repo && !strcmp(name, "repo.path")) else if (ctx.repo && !strcmp(name, "repo.path"))
ctx.repo->path = trim_end(value, '/'); 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); repo_config(ctx.repo, name + 5, value);
else if (!strcmp(name, "readme") && value != NULL) else if (!strcmp(name, "readme") && value != NULL)
string_list_append(&ctx.cfg.readme, xstrdup(value)); 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; ctx.cfg.branch_sort = 1;
if (!strcmp(value, "name")) if (!strcmp(value, "name"))
ctx.cfg.branch_sort = 0; ctx.cfg.branch_sort = 0;
} else if (!prefixcmp(name, "mimetype.")) } else if (starts_with(name, "mimetype."))
add_mimetype(name + 9, value); add_mimetype(name + 9, value);
else if (!strcmp(name, "include")) else if (!strcmp(name, "include"))
parse_configfile(expand_macros(value), config_cb); parse_configfile(expand_macros(value), config_cb);
@ -454,7 +454,7 @@ static char *guess_defbranch(void)
unsigned char sha1[20]; unsigned char sha1[20];
ref = resolve_ref_unsafe("HEAD", sha1, 0, NULL); ref = resolve_ref_unsafe("HEAD", sha1, 0, NULL);
if (!ref || prefixcmp(ref, "refs/heads/")) if (!ref || !starts_with(ref, "refs/heads/"))
return "master"; return "master";
return xstrdup(ref + 11); return xstrdup(ref + 11);
} }
@ -941,28 +941,28 @@ static void cgit_parse_args(int argc, const char **argv)
exit(0); exit(0);
} }
if (!prefixcmp(argv[i], "--cache=")) { if (starts_with(argv[i], "--cache=")) {
ctx.cfg.cache_root = xstrdup(argv[i] + 8); ctx.cfg.cache_root = xstrdup(argv[i] + 8);
} else if (!strcmp(argv[i], "--nocache")) { } else if (!strcmp(argv[i], "--nocache")) {
ctx.cfg.nocache = 1; ctx.cfg.nocache = 1;
} else if (!strcmp(argv[i], "--nohttp")) { } else if (!strcmp(argv[i], "--nohttp")) {
ctx.env.no_http = "1"; 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); 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); 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); 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.head = xstrdup(argv[i] + 7);
ctx.qry.has_symref = 1; 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.sha1 = xstrdup(argv[i] + 7);
ctx.qry.has_sha1 = 1; 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); ctx.qry.ofs = atoi(argv[i] + 6);
} else if (!prefixcmp(argv[i], "--scan-tree=") || } else if (starts_with(argv[i], "--scan-tree=") ||
!prefixcmp(argv[i], "--scan-path=")) { starts_with(argv[i], "--scan-path=")) {
/* /*
* HACK: The global snapshot bit mask defines the set * HACK: The global snapshot bit mask defines the set
* of allowed snapshot formats, but the config file * of allowed snapshot formats, but the config file

2
git

@ -1 +1 @@
Subproject commit 0bc85abb7aa9b24b093253018801a0fb43d01122 Subproject commit e156455ea49124c140a67623f22a393db62d5d98

@ -147,25 +147,25 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
if (p == NULL) if (p == NULL)
return ret; return ret;
if (prefixcmp(p, "tree ")) if (!starts_with(p, "tree "))
die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); die("Bad commit: %s", sha1_to_hex(commit->object.sha1));
else else
p += 46; // "tree " + hex[40] + "\n" p += 46; // "tree " + hex[40] + "\n"
while (!prefixcmp(p, "parent ")) while (starts_with(p, "parent "))
p += 48; // "parent " + hex[40] + "\n" 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, p = parse_user(p + 7, &ret->author, &ret->author_email,
&ret->author_date); &ret->author_date);
} }
if (p && !prefixcmp(p, "committer ")) { if (p && starts_with(p, "committer ")) {
p = parse_user(p + 10, &ret->committer, &ret->committer_email, p = parse_user(p + 10, &ret->committer, &ret->committer_email,
&ret->committer_date); &ret->committer_date);
} }
if (p && !prefixcmp(p, "encoding ")) { if (p && starts_with(p, "encoding ")) {
p += 9; p += 9;
t = strchr(p, '\n'); t = strchr(p, '\n');
if (t) { if (t) {
@ -244,7 +244,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)
if (*p == '\n') if (*p == '\n')
break; break;
if (!prefixcmp(p, "tagger ")) { if (starts_with(p, "tagger ")) {
p = parse_user(p + 7, &ret->tagger, &ret->tagger_email, p = parse_user(p + 7, &ret->tagger, &ret->tagger_email,
&ret->tagger_date); &ret->tagger_date);
} else { } else {

@ -61,7 +61,7 @@ static int gitconfig_config(const char *key, const char *value, void *cb)
config_fn(repo, "desc", value); config_fn(repo, "desc", value);
else if (!strcmp(key, "gitweb.category")) else if (!strcmp(key, "gitweb.category"))
config_fn(repo, "section", value); config_fn(repo, "section", value);
else if (!prefixcmp(key, "cgit.")) else if (starts_with(key, "cgit."))
config_fn(repo, key + 5, value); config_fn(repo, key + 5, value);
return 0; return 0;
@ -105,7 +105,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
return; return;
strbuf_setlen(path, pathlen); strbuf_setlen(path, pathlen);
if (prefixcmp(path->buf, base)) if (!starts_with(path->buf, base))
strbuf_addbuf(&rel, path); strbuf_addbuf(&rel, path);
else else
strbuf_addstr(&rel, path->buf + strlen(base) + 1); 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] == '/') else if (rel.len && rel.buf[rel.len - 1] == '/')
strbuf_setlen(&rel, rel.len - 1); strbuf_setlen(&rel, rel.len - 1);
fprintf(stderr, "add_repo(): %s\n", rel.buf);
repo = cgit_add_repo(rel.buf); repo = cgit_add_repo(rel.buf);
config_fn = fn; config_fn = fn;
if (ctx.cfg.enable_git_config) { 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'; *slash = '\0';
repo->section = xstrdup(rel.buf); repo->section = xstrdup(rel.buf);
*slash = '/'; *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); repo->name += strlen(repo->section);
if (*repo->name == '/') if (*repo->name == '/')
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); size_t pathlen = strlen(path);
struct stat st; struct stat st;
fprintf(stderr, "scan_path(): %s\n", path);
if (!dir) { if (!dir) {
fprintf(stderr, "Error opening directory %s: %s (%d)\n", fprintf(stderr, "Error opening directory %s: %s (%d)\n",
path, strerror(errno), errno); 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)); strbuf_add(&pathbuf, path, strlen(path));
if (is_git_dir(pathbuf.buf)) { if (is_git_dir(pathbuf.buf)) {
fprintf(stderr, "scan_path() is_git_dir: %s\n", path);
add_repo(base, &pathbuf, fn); add_repo(base, &pathbuf, fn);
goto end; goto end;
} }

@ -63,7 +63,7 @@ static void send_file(char *path)
} }
ctx.page.mimetype = "application/octet-stream"; ctx.page.mimetype = "application/octet-stream";
ctx.page.filename = path; 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; ctx.page.filename += strlen(ctx.repo->path) + 1;
cgit_print_http_headers(); cgit_print_http_headers();
html_include(path); html_include(path);

@ -63,21 +63,21 @@ void show_commit_decorations(struct commit *commit)
deco = lookup_decoration(&name_decoration, &commit->object); deco = lookup_decoration(&name_decoration, &commit->object);
html("<span class='decoration'>"); html("<span class='decoration'>");
while (deco) { while (deco) {
if (!prefixcmp(deco->name, "refs/heads/")) { if (starts_with(deco->name, "refs/heads/")) {
strncpy(buf, deco->name + 11, sizeof(buf) - 1); strncpy(buf, deco->name + 11, sizeof(buf) - 1);
cgit_log_link(buf, NULL, "branch-deco", buf, NULL, cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
ctx.qry.vpath, 0, NULL, NULL, ctx.qry.vpath, 0, NULL, NULL,
ctx.qry.showmsg); 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); strncpy(buf, deco->name + 15, sizeof(buf) - 1);
cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); 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); strncpy(buf, deco->name + 10, sizeof(buf) - 1);
cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf); 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) if (!ctx.repo->enable_remote_branches)
goto next; goto next;
strncpy(buf, deco->name + 13, sizeof(buf) - 1); 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)
return; return;
basename = cgit_repobasename(repo->url); 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])) if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]))
ref++; ref++;
if (isdigit(ref[0])) { if (isdigit(ref[0])) {
@ -239,9 +239,9 @@ void cgit_print_refs()
html("<table class='list nowrap'>"); 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); 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); cgit_print_tags(0);
else { else {
cgit_print_branches(0); cgit_print_branches(0);

@ -99,7 +99,7 @@ static int is_in_url(struct cgit_repo *repo)
{ {
if (!ctx.qry.url) if (!ctx.qry.url)
return 1; return 1;
if (repo->url && !prefixcmp(repo->url, ctx.qry.url)) if (repo->url && starts_with(repo->url, ctx.qry.url))
return 1; return 1;
return 0; return 0;
} }

@ -128,7 +128,7 @@ const char *cgit_repobasename(const char *reponame)
/* strip trailing slashes */ /* strip trailing slashes */
while (p && rvbuf[p] == '/') rvbuf[p--] = 0; while (p && rvbuf[p] == '/') rvbuf[p--] = 0;
/* strip trailing .git */ /* 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; p -= 3; rvbuf[p--] = 0;
} }
/* strip more trailing slashes if any */ /* strip more trailing slashes if any */

@ -99,7 +99,7 @@ static const struct cgit_snapshot_format *get_format(const char *filename)
const struct cgit_snapshot_format *fmt; const struct cgit_snapshot_format *fmt;
for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) { for (fmt = cgit_snapshot_formats; fmt->suffix; fmt++) {
if (!suffixcmp(filename, fmt->suffix)) if (ends_with(filename, fmt->suffix))
return fmt; return fmt;
} }
return NULL; return NULL;
@ -151,7 +151,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename,
goto out; goto out;
reponame = cgit_repobasename(url); reponame = cgit_repobasename(url);
if (prefixcmp(snapshot.buf, reponame) == 0) { if (starts_with(snapshot.buf, reponame)) {
const char *new_start = snapshot.buf; const char *new_start = snapshot.buf;
new_start += strlen(reponame); new_start += strlen(reponame);
while (new_start && (*new_start == '-' || *new_start == '_')) while (new_start && (*new_start == '-' || *new_start == '_'))

@ -116,7 +116,7 @@ static char* append_readme_path(const char *filename, const char *ref, const cha
if (!ref) { if (!ref) {
resolved_base = realpath(base_dir, NULL); resolved_base = realpath(base_dir, NULL);
resolved_full = realpath(full_path, 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); free(full_path);
full_path = NULL; full_path = NULL;
} }

Loading…
Cancel
Save