All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] gitweb: Add committags support (take 2)
@ 2006-12-03 23:01 Jakub Narebski
  2006-12-04  2:38 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Narebski @ 2006-12-03 23:01 UTC (permalink / raw)
  To: git

This is my second attemt at adding properly committags support, similar
to what gitweb-xmms2 added in e89abf232a83e579b2bbc76398aefa048661dddf.

In this attempt I follow Junio idea of sequential committags support,
marking some fragments as not-for-parsing for later committags nor
esc_html, instead of building the list of literal replacements to be
applied simultaneously.

The plan of patch series is the following:
 * [PATCH 1/3] gitweb: Add committags support
   (which would add generic committags support, reusing existing
    infrastructure of commit message line by line parsing and
    simplification: leave git_print_log as is, replacing only
    format_log_line_html by committags capable version)
 * [PATCH 2/3] gitweb: Abuse committags support
   (which would use committags for marking signoff lines, and for
    commit message simplification: compacting empty lines, removing
    initial and trailing empty lines)
 * [PATCH 3/3] gitweb: Use committags in subject line and tag comment
   (which would add committags support to subject line/title of commit,
    which is first line of commit message, and to tag message/comment)

But there are still some problems to be solved before posting proper
even the first patch; I'll discuss them part by part.

1. Should we provide examples of committags, even if they _have_ to have
be per project, or at least per gitweb instalation configuration, like
bugtracker support (depending on the bugtracker used by
project/projects) and message id support (depending on mailing list
archive project/projects use)? So far I have come with the following
committag examples (they are for [PATCH 1/3] in the series, so they
don't include signoff committag, not empty_lines_simplification
committag).

Should we use anonymous subroutines, or should we define one subroutine
per committag (how to name them: format_<name>_tag, or <name>_committag,
or committag_<name>,... ?) and reference it? The code below uses
anonymous subroutines.

The subroutine should return either reference to scalar which means
"do not process", scalar which means changed available for further
processing, or void (undef) which means no change. In [PATCH 2/3] we
will enable returning also list of elements, each of which could be
reference to scalar or scalar (for example signoff would return three
element list: opening span element as ref, signoff text as scalar,
closing span element as ref).

  our %committags = (
  	'sha1' => {
  		'pattern' => qr/[0-9a-fA-F]{40}/,
  		'sub' => sub {
  			my $hash_text = shift;
  			my $type = git_get_type($hash_text);
  			if ($type) {
  				return \$cgi->a({-href => href(action=>$type, hash=>$hash_text),
  				                -class => "text"}, $hash_text);
  			}
  			return undef;
  		},
  	},
  	'mantis' => {
  		'pattern' => qr/(BUG|FEATURE)\(\d+\)/,
  		'options' => [ 'http://bugs.xmms2.xmms.se/view.php?id=' ],
  		'sub' => sub {
  			my $match = shift;
  			my $URL = shift;
  			my ($issue) = $match =~ /(\d+)/;
  			return
  				\$cgi->a({-href => "$URL$issue"},
  				         $match);
  		},
  	},
  	'bugzilla' => {
  		'pattern' => qr/bug\s+\d+/,
  		'options' => [ 'http://bugzilla.kernel.org/show_bug.cgi?id=' ],
  		'sub' => sub {
  			my $match = shift;
  			my $URL = shift;
  			my ($bugno) = $match =~ /(\d+)/;
  			return
  				\$cgi->a({-href => "$URL=$bugno"},
  				         $match);
  		},
  	},
  	'URL' => {
  		'pattern' => qr!(http|ftp)s?://[a-zA-Z0-9%./]+[a-zA-Z0-9/]!,
  		'sub' => sub {
  			my $url = shift;
  			return
  				\$cgi->a({-href => $url},
  				         $url); # should be perhaps shortened
  		},
  	},
  	# this is committags v1 subroutine
  	'message_id' => { # use mailing list archive
  		'pattern' => qr!(message|msg)-id:?\s+<[^>]*>;!i,
  		'options' => [ 'http://news.gmane.org/find-root.php?message_id=' ],
  		'sub' => sub {
  			my $text = shift;
  			my $URL = shift;
  
  			$text =~ m/<([^>]*)>/;
  			my $msgid = $1;
  			my $link = $cgi->a({-href => "$URL<$msgid>"},
  			                   $msgid);
  			$text =~ s/$msgid/$link/;
  
  			return \$text;
  		},
  	},
  );

From those committags, only 'sha1' (used now in the limited commitsha
form currently in gitweb) and 'URL' are installation independent.
For xmms2 the 'mantis' tag is needed; for Linux kernel it would be nice
to have both 'bugzilla' and 'message_id' (with some LKML archive) used.

By the way, if you have ideas for other committags, please do write.
For example should esc_html be the last committag?


2. We might not want to use all defined committags in %committags hash.
We might want only some of them for commit message [body], some of them
for subject line, and some of them for tag message. Additionally the
_sequence_ of committags is important. As we cannot rely on 
"keys %committags" to be in any specific order, we have to provide
the ordering ourself. My idea is to use array with the hash keys
(the names of committags) to both define which committags are enabled,
and the sequence of committags itself.

In [PATCH 1/3] there is need for only one such array.

  our @committags = ('sha1');


3. To not split message into many fragments we concatenate strings
if possible. This happens when committag subroutine returns string
(for example we might want to hyperlink only bug number in 'bugzilla'
committag), or return undef (for example 'sha1' committag if the
there does not exist object with given hash, for example in the commit
message of commit cherrypicked from no longer existing branch).

This is example where Perl subroutine prototypes makes sense.

  # push_or_append ARRAY,LIST
  # if ARRAY ends with scalar, and LIST begins with scalar, concatenate
  sub push_or_append (\@@) {
  	my $list = shift;
  
  	if (ref $_[0] || ! @$list || ref $list->[-1]) {
  		push @$list, @_;
  	} else {
  		my $a = pop @$list;
  		my $b = shift @_;
  
  		push @$list, $a . $b, @_;
  	}
  	# imitate push
  	return scalar @$list;
  }


4. Here is the main subroutine for committags support, currently without
the extra parts which would allow committags in the subject line: the
subject is link (<a> element) itself, and in (X)HTML link elements cannot
be nested, so the encompassing <a> element has to be closed and reopened).

I have thought about three solutions, neither without disadvantages.
 * Mark committag as returning link in %committag hash, and wrap it in
   the format_log_line_html subroutine. Disadvantages: prone to config
   errors, doesn't work if link is only part of replacement.
 * Use special a_link subroutine in the committag subs instead of
   $cgi->a(). Disadvantages: need to pass attributes of encompassing
   <a> element to committag subroutine, prone to committag subroutine
   coding errors.
 * Wrap on dereferencing in the final output stage, checking if referenced
   string is wholly <a> element. Disadvantages: committags subroutine
   must return <a> elements separately.

Well, yet another solution would be to forbid committags support in the
subject/title line. gitweb-xmms2 tries to implement this, but not fully,
and not without errors.

  sub format_log_line_html {
	my $line = shift;
	my @committags = @_;

	my @list = ( $line );

   COMMITTAG:
  	foreach my $ctname (@committags) {
  		next COMMITTAG unless exists $committags{$ctname};
  
  		my @opts =
  			exists $committags{$ctname}{'options'} ?
  			@{$committags{$ctname}{'options'}} :
  			();
  		my @newlist = ();

  	PART:
  		foreach my $part (@list) {
  			next PART unless $part;
  			if (ref($part)) {
  				push @newlist, $part;
  				next PART;
  			}
  
  			my $oldpos = 0;
  		MATCH:
  			while ($part =~ m/($committags{$ctname}{'pattern'})/gc) {
  				my $match = $1;
  				my ($prepos, $postpos) = ($-[0], $+[0]);
  				my $repl = $committags{$ctname}{'sub'}->($match, @opts);
  
  				if (defined $repl) {
  					my $pre = substr($part, $oldpos, $prepos - $oldpos);
  
  					push_or_append @newlist, $pre if $pre;
  					push_or_append @newlist, $repl;
  				} else {
  					my $all = substr($part, $oldpos, $postpos - $oldpos);
  
  					push_or_append @newlist, $all if $all;
  				}
  
  				$oldpos = $postpos;
  			} # end while [regexp matches]
  
  			my $rest = substr($part, $oldpos);
  			push_or_append @newlist, $rest if $rest;
  
  		} # end foreach (@list)
  
  		@list = @newlist;
  	} # end foreach (@committags)
  
  	# print it
  	my $result = '';
  	for my $part (@list) {
  		if (ref($part)) {
  			$result .= $$part;
  		} else {
  			$result .= esc_html($part, -nbsp=>1);
 		}
  	}
  
  	return $result;
  }

-- 
Jakub Narebski

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-03 23:01 [RFC] gitweb: Add committags support (take 2) Jakub Narebski
@ 2006-12-04  2:38 ` Junio C Hamano
  2006-12-04 10:33   ` Jakub Narebski
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2006-12-04  2:38 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> writes:

> The subroutine should return either reference to scalar which means
> "do not process", scalar which means changed available for further
> processing, or void (undef) which means no change. In [PATCH 2/3] we
> will enable returning also list of elements, each of which could be
> reference to scalar or scalar (for example signoff would return three
> element list: opening span element as ref, signoff text as scalar,
> closing span element as ref).

Personally I think that "list of elements" should be in the
first patch to build the foundation.

>   our %committags = (
>   	'sha1' => {
>   		'pattern' => qr/[0-9a-fA-F]{40}/,
>   		'sub' => sub {
>   			my $hash_text = shift;
>   			my $type = git_get_type($hash_text);
>   			if ($type) {
>   				return \$cgi->a({-href => href(action=>$type, hash=>$hash_text),
>   				                -class => "text"}, $hash_text);
>   			}
>   			return undef;
>   		},
>   	},

It might make sense to do a /[0-9a-f]{8,40}/ pattern, and make
sure that the named object exists in the sub (which you already
do).  People often write abbreviated commit object name that has
a high chance of staying unique during the life of the project.

>   	'mantis' => {
>   		'pattern' => qr/(BUG|FEATURE)\(\d+\)/,
>   	'bugzilla' => {
>   		'pattern' => qr/bug\s+\d+/,

This is not wrong per-se but somehow feels funny.  It feels as
if there is a convention that bugzilla bugs are usually spelled
in lowercase while mantis bugs are in uppercase, but I do not
think you are suggesting that.

I do not know how this %committags{} is used per project.  With
a setting like repo.or.cz, it is likely that one instance of
gitweb is serving unrelated projects that have their issue
tracker at different locations using different "committags"
convention.  Is the idea to eventually allow enabling/disabling
elements from the global %committags per repository somehow
(perhaps not just enable/disable but even overriding patterns or
parameters)?

> 3. To not split message into many fragments we concatenate strings
> if possible.

I do not know why "avoiding splits" is needed, if it raises 
issues that you need to ask the list about in a message like
this...

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-04  2:38 ` Junio C Hamano
@ 2006-12-04 10:33   ` Jakub Narebski
  2006-12-04 10:53     ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Narebski @ 2006-12-04 10:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> The subroutine should return either reference to scalar which means
>> "do not process", scalar which means changed available for further
>> processing, or void (undef) which means no change. In [PATCH 2/3] we
>> will enable returning also list of elements, each of which could be
>> reference to scalar or scalar (for example signoff would return three
>> element list: opening span element as ref, signoff text as scalar,
>> closing span element as ref).
> 
> Personally I think that "list of elements" should be in the
> first patch to build the foundation.

O.K. (By the way, that is why I posted this RFC without sending patch.)
Especially that in this version this is easy and there are no reasons
against it (in previous version %committag entries had 'islink' field,
and returned value was "wrapped" in format_log_line_html in
</a>...<a ...>; I think I'll chose pre-output wrapping <a> elements).

>>   our %committags = (
>>   	'sha1' => {
>>   		'pattern' => qr/[0-9a-fA-F]{40}/,
>>   		'sub' => sub {
>>   			my $hash_text = shift;
>>   			my $type = git_get_type($hash_text);
>>   			if ($type) {
>>   				return \$cgi->a({-href => href(action=>$type, hash=>$hash_text),
>>   				                -class => "text"}, $hash_text);
>>   			}
>>   			return undef;
>>   		},
>>   	},
> 
> It might make sense to do a /[0-9a-f]{8,40}/ pattern, and make
> sure that the named object exists in the sub (which you already
> do).  People often write abbreviated commit object name that has
> a high chance of staying unique during the life of the project.

That's right. I'll do it. By the way, it might make sense to add 
qr/\bv[0-9]+(\.[0-9]+){1,3}(-[a-z]+[0-9]+)\b/ to match "version" tags.

I have one gripe about "git-cat-file -t". I'd like it to have 
-q/--quiet, -s/--silent, --hush (or --dont-spew-errors-on-stdout)
which would prohibit writing "object not found" errors on stderr
(and in gitweb case to webserver logs). I know I can use "git-cat-file -e"
to check if object exists, or modify git_get_type subroutine

  # get type of given object
  sub git_get_type {
	my $hash = shift;
  	my $git_command = git_cmd_str();
  
  	open my $fd, "-|",
  		"$git_command cat-file -t $hash 2>/dev/null"
  		or return '';
  	my $type = <$fd>;
  	close $fd
  		or return '';
  	chomp $type;
  	return $type;
  }

but both those solutions means one fork more.

>>   	'mantis' => {
>>   		'pattern' => qr/(BUG|FEATURE)\(\d+\)/,
>>   	'bugzilla' => {
>>   		'pattern' => qr/bug\s+\d+/,
> 
> This is not wrong per-se but somehow feels funny.  It feels as
> if there is a convention that bugzilla bugs are usually spelled
> in lowercase while mantis bugs are in uppercase, but I do not
> think you are suggesting that.

The Mantis pattern is taken from committags support in gitweb-xmms2,
http://git.xmms.se/?p=gitweb-xmms2.git while Bugzilla pattern is
taken from Mozilla Bugzilla entries.
 
> I do not know how this %committags{} is used per project.  With
> a setting like repo.or.cz, it is likely that one instance of
> gitweb is serving unrelated projects that have their issue
> tracker at different locations using different "committags"
> convention.  Is the idea to eventually allow enabling/disabling
> elements from the global %committags per repository somehow
> (perhaps not just enable/disable but even overriding patterns or
> parameters)?

I have thought about putting %committags and @committags before
loading config file
  do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
which can load config file depending on the project, but perhaps
it is too complicated solution.

Another solution would be to add 'committags' feature, which would
control at least some of the configurable elements of %committags
and @committags (of committags support). At minimum control which
committags are turned on, and in what sequence.

>> 3. To not split message into many fragments we concatenate strings
>> if possible.
> 
> I do not know why "avoiding splits" is needed, if it raises 
> issues that you need to ask the list about in a message like
> this...

"Avoiding splits" is needed first for performance, and second to
avoid situation where pattern would match on the boundary between
two strings in a list of tokens to process.

The improved version of push_or_append follows:

  sub push_or_append (\@@) {
  	my $list = shift;
  
  	if (ref $_[0] || ref $list->[-1] || ! @$list) {
  		return push @$list, @_;
  	} else {
  		my $a = pop @$list;
  		my $b = shift @_;
  
  		return push @$list, $a . $b, @_;
  	}
  }


Or the variant which I wouldn't use ;-P (well, at least not in the
form below).

  sub push_or_append (\@@) {
  	my $aref = shift;
  	my @list = @_;
  
  	try {
  		return push @$aref[0..$#$aref-1],
  		            $aref->[-1] . $list[0],
  		            @list[1..$#list]
  	} catch {
  		return push @$aref, @list;
  	}
  }

-- 
Jakub Narebski

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-04 10:33   ` Jakub Narebski
@ 2006-12-04 10:53     ` Junio C Hamano
  2006-12-04 11:33       ` Jakub Narebski
  2006-12-06 12:51       ` Jakub Narebski
  0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2006-12-04 10:53 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> writes:

> I have one gripe about "git-cat-file -t". I'd like it to have 
> -q/--quiet, -s/--silent, --hush (or --dont-spew-errors-on-stdout)
> which would prohibit writing "object not found" errors on stderr
> (and in gitweb case to webserver logs). I know I can use "git-cat-file -e"
> to check if object exists, or modify git_get_type subroutine
>
>   # get type of given object
>   sub git_get_type {
> 	my $hash = shift;
>   	my $git_command = git_cmd_str();
>   
>   	open my $fd, "-|",
>   		"$git_command cat-file -t $hash 2>/dev/null"
>   		or return '';

It is one thing if you tend to randomly throw garbage at this
function and use it to check for object's existence, but I hope
you are already checking the user input (which is what $hash is,
I think, here), and the object is supposed to exist in the
repository you are looking at.  In such a case, I think you and
your server administrator have right to know about that
situation; I do not see why you would want to squelch it.

>> I do not know how this %committags{} is used per project.  With
>> a setting like repo.or.cz, it is likely that one instance of
>> gitweb is serving unrelated projects that have their issue
>> tracker at different locations using different "committags"
>> convention.  Is the idea to eventually allow enabling/disabling
>> elements from the global %committags per repository somehow
>> (perhaps not just enable/disable but even overriding patterns or
>> parameters)?
>
> I have thought about putting %committags and @committags before
> loading config file
>   do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
> which can load config file depending on the project, but perhaps
> it is too complicated solution.

I think you are talking about a gitweb-instance wide
customization, but that's not what I meant.  I meant per-project
configuration where w/git-gui.git and w/git.git are served by
the same instance of gitweb but have pointers to different issue
trackers.

>>> 3. To not split message into many fragments we concatenate strings
>>> if possible.
>> 
>> I do not know why "avoiding splits" is needed, if it raises 
>> issues that you need to ask the list about in a message like
>> this...
>
> "Avoiding splits" is needed first for performance, and second to
> avoid situation where pattern would match on the boundary between
> two strings in a list of tokens to process.

I wouldn't know if constantly splitting and then concatenating
is faster than just concatenatting once before output without
benchmarking, so I'd refrain from talking about performance.
Two string case may be a valid concern, though.

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-04 10:53     ` Junio C Hamano
@ 2006-12-04 11:33       ` Jakub Narebski
  2006-12-05  1:08         ` Junio C Hamano
  2006-12-06 12:51       ` Jakub Narebski
  1 sibling, 1 reply; 11+ messages in thread
From: Jakub Narebski @ 2006-12-04 11:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Dnia poniedziałek 4. grudnia 2006 11:53, Junio C Hamano napisał:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> I have one gripe about "git-cat-file -t". I'd like it to have 
>> -q/--quiet, -s/--silent, --hush (or --dont-spew-errors-on-stdout)
>> which would prohibit writing "object not found" errors on stderr
>> (and in gitweb case to webserver logs). I know I can use
>> "git-cat-file -e" to check if object exists, or modify git_get_type
>> subroutine 
>>
>>   # get type of given object
>>   sub git_get_type {
>> 	my $hash = shift;
>>   	my $git_command = git_cmd_str();
>>   
>>   	open my $fd, "-|",
>>   		"$git_command cat-file -t $hash 2>/dev/null"
>>   		or return '';
> 
> It is one thing if you tend to randomly throw garbage at this
> function and use it to check for object's existence, but I hope
> you are already checking the user input (which is what $hash is,
> I think, here), and the object is supposed to exist in the
> repository you are looking at.  In such a case, I think you and
> your server administrator have right to know about that
> situation; I do not see why you would want to squelch it.

I'm sorry, I should mention that this "quiet" mode of operation is 
needed _only_ for committags support, for example by using
git_get_type($hash_text, -quiet=>1) in 'sha1' committag subroutine.

You might have sha1 ids in commit message which no longer point to valid 
(existing) object, for example commit which is result of 
"git cherry-pick -x" from no longer existing temporary branch, or commit 
which is result of "git revert" on a branch which got rebased (but not 
reorganized), or shortened sha1 which is no longer unique. This should 
not cause errors to be written to webserver log.
 

By the way, is it better to use anonymous subroutines for committags 
subs, or use explicit subroutines?

>>> I do not know how this %committags{} is used per project.  With
>>> a setting like repo.or.cz, it is likely that one instance of
>>> gitweb is serving unrelated projects that have their issue
>>> tracker at different locations using different "committags"
>>> convention.  Is the idea to eventually allow enabling/disabling
>>> elements from the global %committags per repository somehow
>>> (perhaps not just enable/disable but even overriding patterns or
>>> parameters)?
>>
>> I have thought about putting %committags and @committags before
>> loading config file
>>   do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
>> which can load config file depending on the project, but perhaps
>> it is too complicated solution.
> 
> I think you are talking about a gitweb-instance wide
> customization, but that's not what I meant.  I meant per-project
> configuration where w/git-gui.git and w/git.git are served by
> the same instance of gitweb but have pointers to different issue
> trackers.

You can always use $ENV{PATH_INFO} in $GITWEB_CONFIG value,
or check out path_info and/or $cgi->params('p') in the config file.
Or perhaps other way to set-up per repository config file.
But this is a bit complicated to set up.

I don't have definite answer about how configure committags
(both the committags enabled and sequence of committags, and
committags parameters) per repository. We can use gitweb.committags 
config variable for committags enables/sequence, but how configure 
committags? gitweb.committag.<name>?

BTW in some cases (e.g. xmms2 projects) issue tracker is common for
all projects hosted.

>>>> 3. To not split message into many fragments we concatenate strings
>>>> if possible.
>>> 
>>> I do not know why "avoiding splits" is needed, if it raises 
>>> issues that you need to ask the list about in a message like
>>> this...
>>
>> "Avoiding splits" is needed first for performance, and second to
>> avoid situation where pattern would match on the boundary between
>> two strings in a list of tokens to process.
> 
> I wouldn't know if constantly splitting and then concatenating
> is faster than just concatenatting once before output without
> benchmarking, so I'd refrain from talking about performance.
> Two string case may be a valid concern, though.

With current implementation it is very easy to switch this one and off.
You simply either use push, or push_or_append (or make push_or_append
do just push).

Previous (not published) version used $acc variable to concatenate 
strings, but I think this solution is better (and simpler).

-- 
Jakub Narebski

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-04 11:33       ` Jakub Narebski
@ 2006-12-05  1:08         ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2006-12-05  1:08 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> writes:

> You might have sha1 ids in commit message which no longer point to valid 
> (existing) object, for example commit which is result of 
> "git cherry-pick -x" from no longer existing temporary branch, or commit 
> which is result of "git revert" on a branch which got rebased (but not 
> reorganized), or shortened sha1 which is no longer unique. This should 
> not cause errors to be written to webserver log.

True.

> By the way, is it better to use anonymous subroutines for committags 
> subs, or use explicit subroutines?

I vaguely recall a thread that discussed pros and cons of using
anonymous subroutines in certain parts of gitweb some time ago
in which even Merlyn had some comments in, but I do not recall
the technical details, sorry.  My gut feeling is that the way
you illustrated your example "our %committags" definition is
fine, but it _might_ turn out that it is easier for sites or for
projects to customize their own set of rewrite rules if you had
explicitly named subroutines available.  I dunno.

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-04 10:53     ` Junio C Hamano
  2006-12-04 11:33       ` Jakub Narebski
@ 2006-12-06 12:51       ` Jakub Narebski
  2006-12-06 19:11         ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Jakub Narebski @ 2006-12-06 12:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:

> Jakub Narebski <jnareb@gmail.com> writes:
>
>> I have thought about putting %committags and @committags before
>> loading config file
>>   do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
>> which can load config file depending on the project, but perhaps
>> it is too complicated solution.
> 
> I think you are talking about a gitweb-instance wide
> customization, but that's not what I meant.  I meant per-project
> configuration where w/git-gui.git and w/git.git are served by
> the same instance of gitweb but have pointers to different issue
> trackers.

It looks like the hardest part with committags support wouldn't be the 
actual implementation of it, but coming with easy and fast way to set 
up those committags.

gitweb-xmms2 project from which the idea of committags support in gitweb 
came (I think, correct me if I'm wrong) avoids this issue by having 
issue tracker / bug tracker the same for all projects served by single 
gitweb installation; the configuration is site-wide, and there is no 
per project committags configuration.


I have imagined the following twofold solution.

1. Make it easier to have per repository gitweb configuration, for
   example by having gitweb configuration file in GIT_DIR for a project,
   "gitweb_conf.perl" by default:

  our $GITWEB_REPO_CONFIG = $ENV{'GITWEB_REPO_CONFIG'} ||
  	"++GITWEB_CONFIG++";
  do "$projectroot/$project/$GITWEB_REPO_CONFIG"
  	if -e "$projectroot/$project/$GITWEB_CONFIG";

2. Put the configuration in config file, using/like %features support.
   For example gitweb.committags.<committag name> would hold parameters
   for <committag>. Committags sequence would be given by sequence of
   entries in config file. Comittags without options would have sole
   variable entry (which I think is equivalent to being bool variable
   and having 1 or 'yes' as value).

   The trouble with this approach is not overriding defaults provided
   while still turning on/off specific committag. And of course the fact
   that for that we need rather config reader in Perl (Git.pm or
   gitweb).

What do you think about it? Junio? Pasky?
-- 
Jakub Narebski

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-06 12:51       ` Jakub Narebski
@ 2006-12-06 19:11         ` Junio C Hamano
  2006-12-06 19:32           ` Jakub Narebski
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2006-12-06 19:11 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git, Pasky Baudis

Jakub Narebski <jnareb@gmail.com> writes:

> 1. Make it easier to have per repository gitweb configuration, for
>    example by having gitweb configuration file in GIT_DIR for a project,
>    "gitweb_conf.perl" by default:
>
>   our $GITWEB_REPO_CONFIG = $ENV{'GITWEB_REPO_CONFIG'} ||
>   	"++GITWEB_CONFIG++";
>   do "$projectroot/$project/$GITWEB_REPO_CONFIG"
>   	if -e "$projectroot/$project/$GITWEB_CONFIG";

I suspect site administrators would hesitate to have perl
scripts in repositories that could run arbitrary things as their
"side effects".

> 2. Put the configuration in config file, using/like %features support.
>    For example gitweb.committags.<committag name> would hold parameters
>    for <committag>. Committags sequence would be given by sequence of
>    entries in config file. Comittags without options would have sole
>    variable entry (which I think is equivalent to being bool variable
>    and having 1 or 'yes' as value).

I think gitweb.* in $GIT_DIR/config and a config reader in Perl
are very sensible things to do, and you would need the config
reader eventually anyway.  The longer we postpone it, the more
we risk the temptation to pollute $GIT_DIR/ with the likes of
"description", "owner", and "homepage", and I do not think we
want to make this worse.

> What do you think about it? Junio? Pasky?

If you are asking Pasky, you should CC him, I think.  I added
him to the CC list.

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-06 19:11         ` Junio C Hamano
@ 2006-12-06 19:32           ` Jakub Narebski
  2006-12-06 19:47             ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Narebski @ 2006-12-06 19:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Pasky Baudis

Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> 2. Put the configuration in config file, using/like %features support.
>>    For example gitweb.committags.<committag name> would hold parameters
>>    for <committag>. Committags sequence would be given by sequence of
>>    entries in config file. Comittags without options would have sole
>>    variable entry (which I think is equivalent to being bool variable
>>    and having 1 or 'yes' as value).
> 
> I think gitweb.* in $GIT_DIR/config and a config reader in Perl
> are very sensible things to do, and you would need the config
> reader eventually anyway.  The longer we postpone it, the more
> we risk the temptation to pollute $GIT_DIR/ with the likes of
> "description", "owner", and "homepage", and I do not think we
> want to make this worse.

By the way, what is the formal structure of the config file? Perhaps
something like the notation used in RFC?

Is it possible (and doesn't crash current git config parser) having

  [gitweb]
  	blame = yes
  	pickaxe = no
  	snapshot = bzip2

  [gitweb "committags"]
  	message-id = "http://news.gmane.org/find-root.php?message_id="
  	mantis = "http://bugs.or.cz/view.php?id="
  	url
  	sha1

in the config file?
-- 
Jakub Narebski

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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-06 19:32           ` Jakub Narebski
@ 2006-12-06 19:47             ` Junio C Hamano
  2006-12-06 20:35               ` Jakub Narebski
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2006-12-06 19:47 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> writes:

> By the way, what is the formal structure of the config file? Perhaps
> something like the notation used in RFC?

Is there an RFC for .INI format?

> Is it possible (and doesn't crash current git config parser) having
>
>   [gitweb]
>   	blame = yes
>   	pickaxe = no
>   	snapshot = bzip2
>
>   [gitweb "committags"]
>   	message-id = "http://news.gmane.org/find-root.php?message_id="
>   	mantis = "http://bugs.or.cz/view.php?id="
>   	url
>   	sha1
>
> in the config file?

If you are asking about [gitweb] stanza and (seemingly
overlapping) [gitweb "foo"] stanza, we already have prior
examples:

	[diff]
        	color = auto
        [diff "color"]
        	whitespace = blue reverse

so your example in the above would be legal (the dash in
'message-id' part might be questionable, though).





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

* Re: [RFC] gitweb: Add committags support (take 2)
  2006-12-06 19:47             ` Junio C Hamano
@ 2006-12-06 20:35               ` Jakub Narebski
  0 siblings, 0 replies; 11+ messages in thread
From: Jakub Narebski @ 2006-12-06 20:35 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> By the way, what is the formal structure of the config file? Perhaps
>> something like the notation used in RFC?
> 
> Is there an RFC for .INI format?

I don't think INI is standarized at all. The format of INI files is not 
well defined. That's why I'd like to know exact format of git INI-like 
config file format.

But what I meant was description of git config file in (used by RFCs)
augmented Backus-Naur Form (BNF) - RFC 4234.
 
>> Is it possible (and doesn't crash current git config parser) having
>>
>>   [gitweb]
>>   	blame = yes
>>   	pickaxe = no
>>   	snapshot = bzip2
>>
>>   [gitweb "committags"]
>>   	message-id = "http://news.gmane.org/find-root.php?message_id="
>>   	mantis = "http://bugs.or.cz/view.php?id="
>>   	url
>>   	sha1
>>
>> in the config file?
> 
> If you are asking about [gitweb] stanza and (seemingly
> overlapping) [gitweb "foo"] stanza, we already have prior
> examples:
> 
> 	[diff]
>         	color = auto
>         [diff "color"]
>         	whitespace = blue reverse
> 
> so your example in the above would be legal (the dash in
> 'message-id' part might be questionable, though).

That's what I was asking for. Thanks for an explanation.

-- 
Jakub Narebski

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

end of thread, other threads:[~2006-12-06 20:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-03 23:01 [RFC] gitweb: Add committags support (take 2) Jakub Narebski
2006-12-04  2:38 ` Junio C Hamano
2006-12-04 10:33   ` Jakub Narebski
2006-12-04 10:53     ` Junio C Hamano
2006-12-04 11:33       ` Jakub Narebski
2006-12-05  1:08         ` Junio C Hamano
2006-12-06 12:51       ` Jakub Narebski
2006-12-06 19:11         ` Junio C Hamano
2006-12-06 19:32           ` Jakub Narebski
2006-12-06 19:47             ` Junio C Hamano
2006-12-06 20:35               ` Jakub Narebski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.