threads / patch / 5839

patchgitweb: Support hiding of chosen repositories from project list

Subject: [PATCH] gitweb: Support hiding of chosen repositories from project list

## tl;dr

5 messages between Oct 6, 2006 and Oct 7, 2006. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Petr Baudis· Oct 6, 2006, 18:28 UTC · lore
This makes it possible to hide certain repository from project list
(while still keeping it accessible, so it's not just an inverse of
 export-ok). By default the file that needs to be created in the
repository is '.hide'.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
 Makefile           |    2 ++
 gitweb/gitweb.perl |   11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
Show changes to 2 files +11 −2

Makefile, gitweb/gitweb.perl

diff --git a/Makefile b/Makefile
index a151029..afb29e9 100644
--- a/Makefile
+++ b/Makefile
@@ -125,6 +125,7 @@ GITWEB_HOME_LINK_STR = projects
 GITWEB_SITENAME =
 GITWEB_PROJECTROOT = /srv/git
 GITWEB_EXPORT_OK =
+GITWEB_HIDE_REPO = .hide
 GITWEB_STRICT_EXPORT =
 GITWEB_BASE_URL =
 GITWEB_LIST =
@@ -673,6 +674,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
 	    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 	    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
+	    -e 's|++GITWEB_HIDE_REPO++|$(GITWEB_HIDE_REPO)|g' \
 	    -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 	    -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
 	    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3a10124..b06e96a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -66,6 +66,11 @@ # show repository only if this file exis
 # (only effective if this variable evaluates to true)
 our $export_ok = "++GITWEB_EXPORT_OK++";
 
+# hide repository from the list if this file exists
+# (the repository is still accessible, just not shown in the project list)
+# (only effective if this variable evaulates to true)
+our $hide_repo = "++GITWEB_HIDE_REPO++";
+
 # only allow viewing of repositories also shown on the overview page
 our $strict_export = "++GITWEB_STRICT_EXPORT++";
 
@@ -864,7 +869,8 @@ sub git_get_projects_list {
 
 				my $subdir = substr($File::Find::name, $pfxlen + 1);
 				# we check related file in $projectroot
-				if (check_export_ok("$projectroot/$subdir")) {
+				if ((!$hide_repo or ! -e "$projectroot/$subdir/$hide_repo")
+				    and check_export_ok("$projectroot/$subdir")) {
 					push @list, { path => $subdir };
 					$File::Find::prune = 1;
 				}
@@ -885,7 +891,8 @@ sub git_get_projects_list {
 			if (!defined $path) {
 				next;
 			}
-			if (check_export_ok("$projectroot/$path")) {
+			if ((!$hide_repo or ! -e "$projectroot/$path/$hide_repo")
+			    and check_export_ok("$projectroot/$path")) {
 				my $pr = {
 					path => $path,
 					owner => decode("utf8", $owner, Encode::FB_DEFAULT),
Junio C Hamano· Oct 7, 2006, 09:33 UTC · re: Petr Baudis · lore

Re: [PATCH] gitweb: Support hiding of chosen repositories from project list

Petr Baudis <pasky@suse.cz> writes:
> @@ -125,6 +125,7 @@ GITWEB_HOME_LINK_STR = projects
>  GITWEB_SITENAME =
>  GITWEB_PROJECTROOT = /srv/git
What code base are you working on?
Show 5 quoted lines
>  GITWEB_EXPORT_OK =
> +GITWEB_HIDE_REPO = .hide
>  GITWEB_STRICT_EXPORT =
>  GITWEB_BASE_URL =
>  GITWEB_LIST =

I see how this feature would be useful, but I am not happy to add random new files under $GIT_DIR/.

Petr Baudis· Oct 7, 2006, 12:32 UTC · re: Junio C Hamano · lore

Re: [PATCH] gitweb: Support hiding of chosen repositories from project list

Dear diary, on Sat, Oct 07, 2006 at 11:33:30AM CEST, I got a letter where Junio C Hamano <junkio@cox.net> said that...

Show 7 quoted lines
> Petr Baudis <pasky@suse.cz> writes:
> 
> > @@ -125,6 +125,7 @@ GITWEB_HOME_LINK_STR = projects
> >  GITWEB_SITENAME =
> >  GITWEB_PROJECTROOT = /srv/git
> 
> What code base are you working on?

Oops. This is the only custom Makefile change I use at repo.or.cz, it kind of slipped through. Yes, I should throw it to Makefile.config or something.

(BTW, I privately consider /pub/git as completely specific to kernel.org setup and pure evil to have as default; I would much prefer to have the default something more standard and LHS-compliant like /srv/git (almost) is. Though I can see the possible pitfalls of changing the default at this point (though Google says that only tipc.cslab.ericsson.net uses the same path), this default leads to people inventing own random paths and chaos reigns: /var/git in Gentoo, /srv/git in SUSE, abomination like /var/cache/git (!) in Debian, others don't seem to bother with gitweb.)

Show 8 quoted lines
> >  GITWEB_EXPORT_OK =
> > +GITWEB_HIDE_REPO = .hide
> >  GITWEB_STRICT_EXPORT =
> >  GITWEB_BASE_URL =
> >  GITWEB_LIST =
> 
> I see how this feature would be useful, but I am not happy to
> add random new files under $GIT_DIR/.
Ok, so it's another thing in the conffile-parser queue.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Martin Waitz· Oct 7, 2006, 18:48 UTC · re: Petr Baudis · lore

Re: [PATCH] gitweb: Support hiding of chosen repositories from project list

hoi :)
On Sat, Oct 07, 2006 at 02:32:00PM +0200, Petr Baudis wrote:
Show 6 quoted lines
> (BTW, I privately consider /pub/git as completely specific to kernel.org
> setup and pure evil to have as default; I would much prefer to have the
> default something more standard and LHS-compliant like /srv/git (almost)
> is. Though I can see the possible pitfalls of changing the default at
> this point (though Google says that only tipc.cslab.ericsson.net uses
> the same path)

Well, Google is not always right. I know at least one more site with this path ;-)

-- 
Martin Waitz
Junio C Hamano· Oct 7, 2006, 19:50 UTC · re: Petr Baudis · lore

Re: [PATCH] gitweb: Support hiding of chosen repositories from project list

Petr Baudis <pasky@suse.cz> writes:
Show 8 quoted lines
> (BTW, I privately consider /pub/git as completely specific to kernel.org
> setup and pure evil to have as default; I would much prefer to have the
> default something more standard and LHS-compliant like /srv/git (almost)
> is. Though I can see the possible pitfalls of changing the default at
> this point (though Google says that only tipc.cslab.ericsson.net uses
> the same path), this default leads to people inventing own random paths
> and chaos reigns: /var/git in Gentoo, /srv/git in SUSE, abomination like
> /var/cache/git (!) in Debian, others don't seem to bother with gitweb.)

While I share the same concern to some degree, distro's usually use whatever path they want to be consistent with their layout (which I hope to converge to LHS or something). As long as we have it easily overridable from their build system (which we do) it should not matter too much for them. For people who build and install their own, I suspect most of them do so because they do not either like the version installed by the sysadmin or they cannot write into system-wide directories, so to them the path needs to be redefined to point at elsewhere anyway and would not be an issue either. But my guess might be grossly wrong.

← back to recent threads