Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.zx2c4.com/cgit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgit.c19
-rw-r--r--cgit.h6
-rw-r--r--scan-tree.c32
-rw-r--r--scan-tree.h4
4 files changed, 28 insertions, 33 deletions
diff --git a/cgit.c b/cgit.c
index c4dc94c..42beace 100644
--- a/cgit.c
+++ b/cgit.c
@@ -41,7 +41,7 @@ static void add_mimetype(const char *name, const char *value)
static void process_cached_repolist(const char *path);
-static void repo_config(struct cgit_repo *repo, const char *name, const char *value)
+void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *value)
{
const char *path;
struct string_list_item *item;
@@ -136,7 +136,7 @@ static void config_cb(const char *name, const char *value)
else if (ctx.repo && !strcmp(name, "repo.path"))
ctx.repo->path = trim_end(value, '/');
else if (ctx.repo && skip_prefix(name, "repo.", &arg))
- repo_config(ctx.repo, arg, value);
+ cgit_repo_config(ctx.repo, arg, value);
else if (!strcmp(name, "readme"))
string_list_append(&ctx.cfg.readme, xstrdup(value));
else if (!strcmp(name, "root-title"))
@@ -256,9 +256,9 @@ static void config_cb(const char *name, const char *value)
process_cached_repolist(expand_macros(value));
else if (ctx.cfg.project_list)
scan_projects(expand_macros(value),
- ctx.cfg.project_list, repo_config);
+ ctx.cfg.project_list);
else
- scan_tree(expand_macros(value), repo_config);
+ scan_tree(expand_macros(value));
else if (!strcmp(name, "scan-hidden-path"))
ctx.cfg.scan_hidden_path = atoi(value);
else if (!strcmp(name, "section-from-path"))
@@ -908,9 +908,9 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
}
idx = cgit_repolist.count;
if (ctx.cfg.project_list)
- scan_projects(path, ctx.cfg.project_list, repo_config);
+ scan_projects(path, ctx.cfg.project_list);
else
- scan_tree(path, repo_config);
+ scan_tree(path);
print_repolist(f, &cgit_repolist, idx);
if (rename(locked_rc.buf, cached_rc))
fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n",
@@ -940,10 +940,9 @@ static void process_cached_repolist(const char *path)
*/
if (generate_cached_repolist(path, cached_rc.buf)) {
if (ctx.cfg.project_list)
- scan_projects(path, ctx.cfg.project_list,
- repo_config);
+ scan_projects(path, ctx.cfg.project_list);
else
- scan_tree(path, repo_config);
+ scan_tree(path);
}
goto out;
}
@@ -1024,7 +1023,7 @@ static void cgit_parse_args(int argc, const char **argv)
*/
ctx.cfg.snapshots = 0xFF;
scan++;
- scan_tree(arg, repo_config);
+ scan_tree(arg);
}
}
if (scan) {
diff --git a/cgit.h b/cgit.h
index 6945eb9..1db3473 100644
--- a/cgit.h
+++ b/cgit.h
@@ -121,9 +121,6 @@ struct cgit_repo {
int ignore;
};
-typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
- const char *value);
-
struct cgit_repolist {
int length;
int count;
@@ -334,7 +331,8 @@ extern const struct cgit_snapshot_format cgit_snapshot_formats[];
extern char *cgit_default_repo_desc;
extern struct cgit_repo *cgit_add_repo(const char *url);
extern struct cgit_repo *cgit_get_repoinfo(const char *url);
-extern void cgit_repo_config_cb(const char *name, const char *value);
+extern void cgit_repo_config(struct cgit_repo *repo, const char *name,
+ const char *value);
extern int chk_zero(int result, char *msg);
extern int chk_positive(int result, char *msg);
diff --git a/scan-tree.c b/scan-tree.c
index 8858b74..867fcf7 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -47,11 +47,10 @@ out:
}
static struct cgit_repo *repo;
-static repo_config_fn config_fn;
static void scan_tree_repo_config(const char *name, const char *value)
{
- config_fn(repo, name, value);
+ cgit_repo_config(repo, name, value);
}
static int gitconfig_config(const char *key, const char *value,
@@ -60,15 +59,15 @@ static int gitconfig_config(const char *key, const char *value,
const char *name;
if (!strcmp(key, "gitweb.owner"))
- config_fn(repo, "owner", value);
+ cgit_repo_config(repo, "owner", value);
else if (!strcmp(key, "gitweb.description"))
- config_fn(repo, "desc", value);
+ cgit_repo_config(repo, "desc", value);
else if (!strcmp(key, "gitweb.category"))
- config_fn(repo, "section", value);
+ cgit_repo_config(repo, "section", value);
else if (!strcmp(key, "gitweb.homepage"))
- config_fn(repo, "homepage", value);
+ cgit_repo_config(repo, "homepage", value);
else if (skip_prefix(key, "cgit.", &name))
- config_fn(repo, name, value);
+ cgit_repo_config(repo, name, value);
return 0;
}
@@ -80,7 +79,7 @@ static char *xstrrchr(char *s, char *from, int c)
return from < s ? NULL : from;
}
-static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
+static void add_repo(const char *base, struct strbuf *path)
{
struct stat st;
struct passwd *pwd;
@@ -122,7 +121,6 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
strbuf_setlen(&rel, rel.len - 1);
repo = cgit_add_repo(rel.buf);
- config_fn = fn;
if (ctx.cfg.enable_git_config) {
strbuf_addstr(path, "config");
git_config_from_file(gitconfig_config, path->buf, NULL);
@@ -185,7 +183,7 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
strbuf_release(&rel);
}
-static void scan_path(const char *base, const char *path, repo_config_fn fn)
+static void scan_path(const char *base, const char *path)
{
DIR *dir = opendir(path);
struct dirent *ent;
@@ -201,12 +199,12 @@ 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)) {
- add_repo(base, &pathbuf, fn);
+ add_repo(base, &pathbuf);
goto end;
}
strbuf_addstr(&pathbuf, "/.git");
if (is_git_dir(pathbuf.buf)) {
- add_repo(base, &pathbuf, fn);
+ add_repo(base, &pathbuf);
goto end;
}
/*
@@ -231,14 +229,14 @@ static void scan_path(const char *base, const char *path, repo_config_fn fn)
continue;
}
if (S_ISDIR(st.st_mode))
- scan_path(base, pathbuf.buf, fn);
+ scan_path(base, pathbuf.buf);
}
end:
strbuf_release(&pathbuf);
closedir(dir);
}
-void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn)
+void scan_projects(const char *path, const char *projectsfile)
{
struct strbuf line = STRBUF_INIT;
FILE *projects;
@@ -255,7 +253,7 @@ void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn
continue;
strbuf_insert(&line, 0, "/", 1);
strbuf_insert(&line, 0, path, strlen(path));
- scan_path(path, line.buf, fn);
+ scan_path(path, line.buf);
}
if ((err = ferror(projects))) {
fprintf(stderr, "Error reading from projectsfile %s: %s (%d)\n",
@@ -265,7 +263,7 @@ void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn
strbuf_release(&line);
}
-void scan_tree(const char *path, repo_config_fn fn)
+void scan_tree(const char *path)
{
- scan_path(path, path, fn);
+ scan_path(path, path);
}
diff --git a/scan-tree.h b/scan-tree.h
index 1afbd4b..def0a7a 100644
--- a/scan-tree.h
+++ b/scan-tree.h
@@ -1,2 +1,2 @@
-extern void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn);
-extern void scan_tree(const char *path, repo_config_fn fn);
+extern void scan_projects(const char *path, const char *projectsfile);
+extern void scan_tree(const char *path);