Skip to contentSkip to conversation

gitweb: Add committags support (take 2)

RFC Jakub Narebski 2 participants 11 messages Aug 11, 2016

lore
Share & tools
lore
#1 lore raw
In reply to Jakub Narebski
Quoted 7 lines · Jakub Narebski

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.

Quoted 5 lines
  our %committags = (
  	'sha1' => {
  		'pattern' => qr/[0-9a-fA-F]{40}/,
  		'sub' => sub {
  			my $hash_text = shift;
Quoted 8 lines
  			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.

Quoted 4 lines
  	'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)?

Quoted 2 lines

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...

#2 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Jakub Narebski

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).

Quoted 2 lines

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).

Quoted 14 lines
Quoted 5 lines
  our %committags = (
  	'sha1' => {
  		'pattern' => qr/[0-9a-fA-F]{40}/,
  		'sub' => sub {
  			my $hash_text = shift;
Quoted 8 lines
  			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;
  		},
  	},
Quoted 4 lines

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.

Quoted 9 lines
Quoted 4 lines
  	'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.

Quoted 8 lines

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.

Quoted 6 lines
Quoted 2 lines

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;
  	}
  }
Signature · 1 line
Jakub Narebski
#6 lore raw
In reply to Junio C Hamano
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Jakub Narebski

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).

Quoted 6 lines

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?

Signature · 1 line
Jakub Narebski
#9 lore raw
In reply to Junio C Hamano
Quoted 18 lines · Junio C Hamano
Quoted 7 lines · Jakub Narebski

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

Quoted 8 lines
  # 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 '';

Quoted 7 lines

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?

Quoted 15 lines
Quoted 9 lines
Quoted 8 lines

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)?

Quoted 5 lines

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.

Quoted 5 lines

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.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

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...

Quoted 8 lines
Quoted 3 lines

"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).

Signature · 1 line
Jakub Narebski
#4 lore raw
In reply to Junio C Hamano
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Jakub Narebski

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.

Quoted 5 lines

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?

Signature · 1 line
Jakub Narebski
#7 lore raw
In reply to Jakub Narebski
Quoted 2 lines · Jakub Narebski

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?

Quoted 7 lines

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

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

Quoted 7 lines

[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).

#0 lore raw

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;
  }
Signature · 1 line
Jakub Narebski
#3 lore raw
In reply to Jakub Narebski
Quoted 6 lines · Jakub Narebski

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

Quoted 8 lines
  # 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.

Quoted 9 lines
Quoted 8 lines

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)?

Quoted 5 lines

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.

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

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.

#5 lore raw
In reply to Jakub Narebski
Quoted 8 lines · Jakub Narebski

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".

Quoted 6 lines

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.

Quoted 1 line

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.

#10 lore raw
In reply to Jakub Narebski
Quoted 6 lines · Jakub Narebski

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.

Quoted 2 lines

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.

#8 lore raw
In reply to Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Jakub Narebski

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.

Quoted 19 lines
Quoted 7 lines

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

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

Quoted 7 lines

[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:

Quoted 7 lines
	[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.

Signature · 1 line
Jakub Narebski