[PATCH 03/07] Refactor repo list scanning.
The Ranger
ranger at risk.ee
Fri Nov 27 21:46:29 CET 2015
---
cgit.c | 18 ++++--------------
scan-tree.c | 5 +++++
scan-tree.h | 1 -
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/cgit.c b/cgit.c
index 75fcc92..0a6473d 100644
--- a/cgit.c
+++ b/cgit.c
@@ -227,9 +227,6 @@ static void config_cb(const char *name, const char *value)
else if (!strcmp(name, "scan-path"))
if (!ctx.cfg.nocache && ctx.cfg.cache_size)
process_cached_repolist(expand_macros(value));
- else if (ctx.cfg.project_list)
- scan_projects(expand_macros(value),
- ctx.cfg.project_list, repo_config);
else
scan_tree(expand_macros(value), repo_config);
else if (!strcmp(name, "scan-hidden-path"))
@@ -870,10 +867,7 @@ static int generate_cached_repolist(const char *path, const char *cached_rc)
goto out;
}
idx = cgit_repolist.count;
- if (ctx.cfg.project_list)
- scan_projects(path, ctx.cfg.project_list, repo_config);
- else
- scan_tree(path, repo_config);
+ scan_tree(path, repo_config);
print_repolist(f, &cgit_repolist, idx);
if (rename(locked_rc.buf, cached_rc))
fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n",
@@ -901,13 +895,9 @@ static void process_cached_repolist(const char *path)
* if we fail to generate a cached repolist, we need to
* invoke scan_tree manually.
*/
- if (generate_cached_repolist(path, cached_rc.buf)) {
- if (ctx.cfg.project_list)
- scan_projects(path, ctx.cfg.project_list,
- repo_config);
- else
- scan_tree(path, repo_config);
- }
+ if (generate_cached_repolist(path, cached_rc.buf))
+ scan_tree(path, repo_config);
+
goto out;
}
diff --git a/scan-tree.c b/scan-tree.c
index b5a10ff..e17bca9 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -261,5 +261,10 @@ void scan_projects(const char *path, const char *projectsfile, repo_config_fn fn
void scan_tree(const char *path, repo_config_fn fn)
{
+ if (ctx.cfg.project_list) {
+ scan_projects(path, ctx.cfg.project_list, fn);
+ return;
+ }
+
scan_path(path, path, fn);
}
diff --git a/scan-tree.h b/scan-tree.h
index 1afbd4b..d510d85 100644
--- a/scan-tree.h
+++ b/scan-tree.h
@@ -1,2 +1 @@
-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);
--
2.1.4
More information about the CGit
mailing list