about summary refs log tree commit diff
path: root/scan-tree.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2014-05-29 17:35:46 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-06-28 15:14:56 +0200
commit79c985e13c10b498c3ea62f4607c2e2a460c3b10 (patch)
treed06ca41cfe2ebb5ff80ae747e38aeaad35734e35 /scan-tree.c
parentremove trailing whitespaces from source files (diff)
downloadcgit-pink-79c985e13c10b498c3ea62f4607c2e2a460c3b10.tar.gz
cgit-pink-79c985e13c10b498c3ea62f4607c2e2a460c3b10.zip
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.
Diffstat (limited to '')
-rw-r--r--scan-tree.c10
1 files changed, 7 insertions, 3 deletions
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;
 	}