git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFD] gitweb configuration
@ 2006-06-17 22:48 Jakub Narebski
  2006-06-17 23:23 ` Petr Baudis
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Narebski @ 2006-06-17 22:48 UTC (permalink / raw)
  To: git

Petr Baudis <pasky@suse.cz> writes:
>  - we might want to have a configuration mechanism in place
>    before enhancing gitweb.  My gut feeling is that we can use
>    [gitweb] section in project.git/config (and probably
>    duplicate first and deprecate later existing "description" as
>    well).

The problem is we have different types of configuration in gitweb, and we
should take care where to put appropriate configuration options/variables.

- build time options, like $gitexecdir ($gitbin now) or $gitweb_version 
  ($version now) which could be set at build time a la ./configure i.e
  my $gitexecdir = "@GIT_EXEC_DIR@"; or something like that.

- gitweb installation options (gitweb version need not to correspond to 
  git version, and we could theoretically have more than one gitweb
  installation while one git-core installation). It was proposed to put
  such options on gitweb.conf file in the same directory as gitweb.cgi.
  Unfortunately if one would want to use git-repo-config for managing
  gitweb.conf one is out of luck: git-repo-config uses $GIT_DIR/config.

  Among installation options we could put also defaults for repository-wide
  (repository specific) options.

  Global gitweb options include:
  * $projectroot - absolute fs-path which will be prepended to the 
    project path, i.e. where projects to display are located (dir)
  * $projects_list - source of projects list (file)
  * $home_text - html text to include at home page (file)
  * $stylesheet - default gitweb stylesheet (file)
  * $git_temp - where to place temporary files (dir)

- repository specific options, of which gitweb for now uses only 
  $GIT_DIR/description, and which could use repository configuration,
  [gitweb] section.

  Repository specific options [can] include:
  * description - One line description of repository; 
    theoretical problem: HTML escaping.
  * blame - to make 'blame'/'annotate' interface available.
  * blobmimemapfile - for repository specific mime map for blob_plain.
  * favicon - if default favicon is not used.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-17 22:48 [RFD] gitweb configuration Jakub Narebski
@ 2006-06-17 23:23 ` Petr Baudis
  2006-06-18  4:00   ` Jakub Narebski
  0 siblings, 1 reply; 12+ messages in thread
From: Petr Baudis @ 2006-06-17 23:23 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Dear diary, on Sun, Jun 18, 2006 at 12:48:12AM CEST, I got a letter
where Jakub Narebski <jnareb@gmail.com> said that...
> Petr Baudis <pasky@suse.cz> writes:
> >  - we might want to have a configuration mechanism in place
> >    before enhancing gitweb.  My gut feeling is that we can use
> >    [gitweb] section in project.git/config (and probably
> >    duplicate first and deprecate later existing "description" as
> >    well).

(Note that this is what Junio said, not me.)

> - gitweb installation options (gitweb version need not to correspond to 
>   git version, and we could theoretically have more than one gitweb
>   installation while one git-core installation). It was proposed to put
>   such options on gitweb.conf file in the same directory as gitweb.cgi.
>   Unfortunately if one would want to use git-repo-config for managing
>   gitweb.conf one is out of luck: git-repo-config uses $GIT_DIR/config.

In the longer term, perhaps this kind of configuration might land in the
global git configuration file.

---
[PATCH] Support for extracting configuration from different files

Add $GIT_CONFIG environment variable whose content is used instead
of .git/config if set. Also add $GIT_CONFIG_LOCAL as a
forward-compatibility cue for whenever we will finally come to support]
global configuration files (properly).

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 Documentation/git-repo-config.txt |   12 ++++++++++++
 config.c                          |   12 +++++++++++-
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index d5142e0..803c0d5 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -73,6 +73,18 @@ OPTIONS
 	List all variables set in .git/config.
 
 
+ENVIRONMENT
+-----------
+
+GIT_CONFIG::
+	Take the configuration from the given file instead of .git/config.
+
+GIT_CONFIG_LOCAL::
+	Currently the same as $GIT_CONFIG; when Git will support global
+	configuration files, this will cause it to take the configuration
+	from the global configuration file in addition to the given file.
+
+
 EXAMPLE
 -------
 
diff --git a/config.c b/config.c
index c474970..42e1493 100644
--- a/config.c
+++ b/config.c
@@ -317,7 +317,17 @@ int git_config_from_file(config_fn_t fn,
 
 int git_config(config_fn_t fn)
 {
-	return git_config_from_file(fn, git_path("config"));
+	const char *filename = git_path("config");
+	/* Forward-compatibility cue: $GIT_CONFIG makes git read _only_
+	 * the given config file, $GIT_CONFIG_LOCAL will make it process
+	 * it in addition to the global config file, the same way it would
+	 * the per-repository config file otherwise. */
+	if (getenv("GIT_CONFIG")) {
+		filename = getenv("GIT_CONFIG");
+	} else if (getenv("GIT_CONFIG_LOCAL")) {
+		filename = getenv("GIT_CONFIG_LOCAL");
+	}
+	return git_config_from_file(fn, filename);
 }
 
 /*

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-17 23:23 ` Petr Baudis
@ 2006-06-18  4:00   ` Jakub Narebski
  2006-06-18  7:42     ` Martin Langhoff
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Narebski @ 2006-06-18  4:00 UTC (permalink / raw)
  To: git

Petr Baudis wrote:

>> - gitweb installation options (gitweb version need not to correspond to 
>>   git version, and we could theoretically have more than one gitweb
>>   installation while one git-core installation). It was proposed to put
>>   such options on gitweb.conf file in the same directory as gitweb.cgi.
>>   Unfortunately if one would want to use git-repo-config for managing
>>   gitweb.conf one is out of luck: git-repo-config uses $GIT_DIR/config.
> 
> In the longer term, perhaps this kind of configuration might land in the
> global git configuration file.

We could use user's "global" configuration file, ~/.gitconfig, in patch
from Johannes Schindelin (and now in 'pu').

So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be 
$GIT_DIR/config or what?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  4:00   ` Jakub Narebski
@ 2006-06-18  7:42     ` Martin Langhoff
  2006-06-18  8:02       ` Jakub Narebski
  2006-06-18  8:38       ` Junio C Hamano
  0 siblings, 2 replies; 12+ messages in thread
From: Martin Langhoff @ 2006-06-18  7:42 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
> $GIT_DIR/config or what?

I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
Given that it works in a CGI environment, it should read
$GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).

cheers,


martin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  7:42     ` Martin Langhoff
@ 2006-06-18  8:02       ` Jakub Narebski
  2006-06-18  8:30         ` Timo Hirvonen
  2006-06-18  8:38       ` Junio C Hamano
  1 sibling, 1 reply; 12+ messages in thread
From: Jakub Narebski @ 2006-06-18  8:02 UTC (permalink / raw)
  To: git

Martin Langhoff wrote:

> On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
>> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
>> $GIT_DIR/config or what?
> 
> I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
> Given that it works in a CGI environment, it should read
> $GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).

When talking about gitweb [installation] configuration, including where to
find GIT projects to display, one needs to remember that gitweb might (and
probably is) installed from binary package and not git.git, and
git/.git/config might not exist.

So we have the following options to separate gitweb-wide options:

- use ~/.gitconfig, /etc/gitconfig or some other global git configuration 
  file, reading values using '$gitexecdir/git-repo-config'.
  Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
  needs to be set in gitweb.cgi, perhaps during the build process.

- use gitweb.conf for configuration, reading values via equivalent of
  'GIT_CONFIG=gitweb.conf $gitexecdir/git-repo-config'. 
  Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
  needs to be set in gitweb.cgi, perhaps during the build process.

- use gitweb.conf for configuration, following the .git/config format,
  writing parsing of ini file (reading only) in Perl from scratch 
  (or use one of many CPAN modules).

- use Perl for configuration file, a la Jon Loeliger <jdl@jdl.com> patch:
   http://marc.theaimsgroup.com/?l=git&m=114308224922372&w=2

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  8:02       ` Jakub Narebski
@ 2006-06-18  8:30         ` Timo Hirvonen
  2006-06-18  9:12           ` Jakub Narebski
  0 siblings, 1 reply; 12+ messages in thread
From: Timo Hirvonen @ 2006-06-18  8:30 UTC (permalink / raw)
  To: jnareb; +Cc: git

Jakub Narebski <jnareb@gmail.com> wrote:

> - use ~/.gitconfig, /etc/gitconfig or some other global git configuration 
>   file, reading values using '$gitexecdir/git-repo-config'.
>   Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
>   needs to be set in gitweb.cgi, perhaps during the build process.

Just use "git command" and you don't have to know $gitexecdir.

-- 
http://onion.dynserv.net/~timo/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  7:42     ` Martin Langhoff
  2006-06-18  8:02       ` Jakub Narebski
@ 2006-06-18  8:38       ` Junio C Hamano
  2006-06-18 13:04         ` Petr Baudis
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2006-06-18  8:38 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: git

"Martin Langhoff" <martin.langhoff@gmail.com> writes:

> On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
>> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
>> $GIT_DIR/config or what?
>
> I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
> Given that it works in a CGI environment, it should read
> $GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).

I am not Pasky, but I think the intent of the patch is to run
"git repo-config" with GIT_CONFIG pointing at /etc/gitweb.conf
to obtain server-wide configuration (e.g. finding out where
repositories are) and then when serving individual repository
(i.e. after we set up GIT_DIR to point at it) run "git
repo-config" without GIT_CONFIG to read per-repository
configuration.  That way we can reuse the configuration parser.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  8:30         ` Timo Hirvonen
@ 2006-06-18  9:12           ` Jakub Narebski
  2006-06-18  9:40             ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Jakub Narebski @ 2006-06-18  9:12 UTC (permalink / raw)
  To: git

Timo Hirvonen wrote:

> Jakub Narebski <jnareb@gmail.com> wrote:
> 
>> - use ~/.gitconfig, /etc/gitconfig or some other global git configuration 
>>   file, reading values using '$gitexecdir/git-repo-config'.
>>   Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
>>   needs to be set in gitweb.cgi, perhaps during the build process.
> 
> Just use "git command" and you don't have to know $gitexecdir.

First, 'git' might be not in PATH for the webserver user which runs
gitweb.cgi.

Second, I guess that '$gitexecdir/git-repo-config' is/can be faster than
'git repo-config', but if 'git' is in the PATH we can set $gitexecdir from
'git --exec-path'.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  9:12           ` Jakub Narebski
@ 2006-06-18  9:40             ` Junio C Hamano
  2006-06-18 10:05               ` Jakub Narebski
  2006-06-18 10:13               ` Martin Langhoff
  0 siblings, 2 replies; 12+ messages in thread
From: Junio C Hamano @ 2006-06-18  9:40 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Timo Hirvonen

Jakub Narebski <jnareb@gmail.com> writes:

> Timo Hirvonen wrote:
>
>> Just use "git command" and you don't have to know $gitexecdir.
>
> First, 'git' might be not in PATH for the webserver user which runs
> gitweb.cgi.

For that we would have a chicken-and-egg problem if we make
configuration mechanism based on git-repo-config, so I would say
per-site customization is needed somehow.

Hardcoding the path into gitweb.cgi could be one way.
Hardcoding the path to gitweb per-site configuration file and
implement the logic to parse the configuration file without
using git-repo-config would be another.  Even if you wanted to
use "git --exec-path" to bootstrap, not having "git" in the path
would make it, eh, cumbersome.

My gut feeling is that it is sensible to assume git is on
everybody's path -- after all the site is running gitweb and
majority would be using binary packaged distribution, so git
would be installed somewhere sensible and accessible.

So I am with Timo on this one, except that in some cases munging
gitweb.cgi script itself might be needed if the installation
chose to hide git somewhere inaccessible from ordinary users.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  9:40             ` Junio C Hamano
@ 2006-06-18 10:05               ` Jakub Narebski
  2006-06-18 10:13               ` Martin Langhoff
  1 sibling, 0 replies; 12+ messages in thread
From: Jakub Narebski @ 2006-06-18 10:05 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> So I am with Timo on this one, except that in some cases munging
> gitweb.cgi script itself might be needed if the installation
> chose to hide git somewhere inaccessible from ordinary users.
                                                ^^^^^^^^^^^^^^

The problem is with webserver user (nobody, web, apache, ...),
which might have nonstandard PATH and/or be run from jail/chroot.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  9:40             ` Junio C Hamano
  2006-06-18 10:05               ` Jakub Narebski
@ 2006-06-18 10:13               ` Martin Langhoff
  1 sibling, 0 replies; 12+ messages in thread
From: Martin Langhoff @ 2006-06-18 10:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jakub Narebski, git, Timo Hirvonen

On 6/18/06, Junio C Hamano <junkio@cox.net> wrote:
> My gut feeling is that it is sensible to assume git is on
> everybody's path -- after all the site is running gitweb and
> majority would be using binary packaged distribution, so git
> would be installed somewhere sensible and accessible.

+1. In the case of binary packages, the maintainer/packager can drop a
config file in /etc/apache/conf.d , so it's unlikely that munging
actually needs to happen.

cheers,


martin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFD] gitweb configuration
  2006-06-18  8:38       ` Junio C Hamano
@ 2006-06-18 13:04         ` Petr Baudis
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Baudis @ 2006-06-18 13:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Martin Langhoff, git

Dear diary, on Sun, Jun 18, 2006 at 10:38:02AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> "Martin Langhoff" <martin.langhoff@gmail.com> writes:
> 
> > On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
> >> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
> >> $GIT_DIR/config or what?
> >
> > I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
> > Given that it works in a CGI environment, it should read
> > $GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).
> 
> I am not Pasky, but I think the intent of the patch is to run
> "git repo-config" with GIT_CONFIG pointing at /etc/gitweb.conf
> to obtain server-wide configuration (e.g. finding out where
> repositories are) and then when serving individual repository
> (i.e. after we set up GIT_DIR to point at it) run "git
> repo-config" without GIT_CONFIG to read per-repository
> configuration.  That way we can reuse the configuration parser.

Yes, if $GIT_CONFIG is set, git should be guaranteed to read _no_ config
file except $GIT_CONFIG. The intent of $GIT_LOCAL_CONFIG was to make it
possible to just override the per-repo configfile location, but it just
felt nice to have - I don't insist on it so if people think it's useless
additional complexity I'm happy to say that one goodbye.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-06-18 13:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-17 22:48 [RFD] gitweb configuration Jakub Narebski
2006-06-17 23:23 ` Petr Baudis
2006-06-18  4:00   ` Jakub Narebski
2006-06-18  7:42     ` Martin Langhoff
2006-06-18  8:02       ` Jakub Narebski
2006-06-18  8:30         ` Timo Hirvonen
2006-06-18  9:12           ` Jakub Narebski
2006-06-18  9:40             ` Junio C Hamano
2006-06-18 10:05               ` Jakub Narebski
2006-06-18 10:13               ` Martin Langhoff
2006-06-18  8:38       ` Junio C Hamano
2006-06-18 13:04         ` Petr Baudis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).