cgit

commit c58cec9dff273b44c428cfaee24e5e3743c0034e

Author: Lukas Fleischer <cgit@cryptocrack.de>

Add repo.hide and repo.ignore

These options can be used to hide a repository from the index or
completely ignore a repository, respectively. They are particularly
useful when used in combination with scan-path.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>

 cgit.c | 6 ++++++
 cgit.h | 2 ++
 cgitrc.5.txt | 10 ++++++++++
 shared.c | 3 +++
 ui-repolist.c | 2 ++


diff --git a/cgit.c b/cgit.c
index 79019c268027343e7944ceab6db35477219e861f..431e325295610ba5eeeff1ce3cdb1954f3012215 100644
--- a/cgit.c
+++ b/cgit.c
@@ -93,6 +93,10 @@ 		else if (!strcmp(name, "email-filter"))
 			repo->email_filter = cgit_new_filter(value, EMAIL);
 		else if (!strcmp(name, "owner-filter"))
 			repo->owner_filter = cgit_new_filter(value, OWNER);
+	} else if (!strcmp(name, "hide")) {
+		repo->hide = atoi(value);
+	} else if (!strcmp(name, "ignore")) {
+		repo->ignore = atoi(value);
 	}
 }
 
@@ -828,6 +832,8 @@ 			fprintf(f, "repo.commit-sort=date\n");
 		else if (repo->commit_sort == 2)
 			fprintf(f, "repo.commit-sort=topo\n");
 	}
+	fprintf(f, "repo.hide=%d\n", repo->hide);
+	fprintf(f, "repo.ignore=%d\n", repo->ignore);
 	fprintf(f, "\n");
 }
 




diff --git a/cgit.h b/cgit.h
index 42140ac4acdb8d59942a5e0abcfb9f7bbbb3bf4b..16f809297fc40d9eedf95a80fcaf7e4caaefb26f 100644
--- a/cgit.h
+++ b/cgit.h
@@ -106,6 +106,8 @@ 	struct cgit_filter *source_filter;
 	struct cgit_filter *email_filter;
 	struct cgit_filter *owner_filter;
 	struct string_list submodules;
+	int hide;
+	int ignore;
 };
 
 typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,




diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index be6703fdb1e0bfce51907c4420dab4ce3d47cff1..e21ece9fd30263b6f8244cf4d86c7a675d0024d8 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -509,6 +509,16 @@ repo.enable-subject-links::
 	A flag which can be used to override the global setting
 	`enable-subject-links'. Default value: none.
 
+repo.hide::
+	Flag which, when set to "1", hides the repository from the repository
+	index. The repository can still be accessed by providing a direct path.
+	Default value: "0". See also: "repo.ignore".
+
+repo.ignore::
+	Flag which, when set to "1", ignores the repository. The repository
+	is not shown in the index and cannot be accessed by providing a direct
+	path. Default value: "0". See also: "repo.hide".
+
 repo.logo::
 	Url which specifies the source of an image which will be used as a logo
 	on this repo's pages. Default value: global logo.




diff --git a/shared.c b/shared.c
index 6e91857066a03faf40ea1153bc8868ee9b29f404..ae17d789f26eb5ea565dba771b7ca132e86fdb45 100644
--- a/shared.c
+++ b/shared.c
@@ -75,6 +75,7 @@ 	ret->email_filter = ctx.cfg.email_filter;
 	ret->owner_filter = ctx.cfg.owner_filter;
 	ret->clone_url = ctx.cfg.clone_url;
 	ret->submodules.strdup_strings = 1;
+	ret->hide = ret->ignore = 0;
 	return ret;
 }
 
@@ -85,6 +86,8 @@ 	struct cgit_repo *repo;
 
 	for (i = 0; i < cgit_repolist.count; i++) {
 		repo = &cgit_repolist.repos[i];
+		if (repo->ignore)
+			continue;
 		if (!strcmp(repo->url, url))
 			return repo;
 	}




diff --git a/ui-repolist.c b/ui-repolist.c
index f929cb79ec05ded2e92deb90e50743dde88d6681..91911e071b2f35fa51bd01e6923bc27c389dd6bd 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -275,6 +275,8 @@
 	html("<table summary='repository list' class='list nowrap'>");
 	for (i = 0; i < cgit_repolist.count; i++) {
 		ctx.repo = &cgit_repolist.repos[i];
+		if (ctx.repo->hide || ctx.repo->ignore)
+			continue;
 		if (!(is_match(ctx.repo) && is_in_url(ctx.repo)))
 			continue;
 		hits++;