gitweb: Different colours for tags and heads
PATCH 1/1 gitweb: Different colours for tags and heads
Hello,
with the following patch there are different colours for tags and heads in gitweb. So you can easily differentiate between them.
Commit ca9e3b124f6313187da641b5cd55100c4ade6a9a
----
gitweb/gitweb.css +9 -0
@@ -330,6 +330,15 @@ span.tag { border-color: #ffffcc #ffee00 #ffee00 #ffffcc; } +span.head { + padding: 0px 4px; + font-size: 10px; + font-weight: normal; + background-color: #aaaaff; + border: 1px solid; + border-color: #ccccff #0033cc #0033cc #ccccff; +} + span.atnight { color: #cc0000; }
gitweb/gitweb.perl +40 -27
190 lines not on this page · raw message
----
Bye,
Thomas
Signature · 2 lines
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
Quoted 7 lines · Thomas Kolejka
Hello,
with the following patch there are different colours for tags and heads in gitweb. So you can easily differentiate between them.
Commit
ca9e3b124f6313187da641b5cd55100c4ade6a9a
Based on which branch? Master, next? Which commit?
By the way, please do not put "Hello," in the commit message part of patch. You can put your comments (like which branch and/or commit is the batch based on) either after "---" and before the patch itself, or at the beginning and separate them from the commit message by "+++" (this separator is supported by git tools, but some people use "-- >8 --" 'scissors' separator). git-format-patch helps in correct formatting, and adds diffstat.
You would also be most probably asked to sign your patches, i.e. add
line at the end of commit message.
I have send patch of similar nature:
"[PATCH 5/5] gitweb: Change appereance of marker of refs pointing to given object"
http://permalink.gmane.org/gmane.comp.version-control.git/24860
in which I split marker for refs poining to given object into
separate span elements. The patch was dropped because it followed first version of "Great subroutine renames" patch.
I've planned on patch which does something similar to yours, but in slightly different way: instead of two calls to git_get_referencing (format_mark_referencing[*1*] after rename) and two calls to read_info_ref (git_get_references after rename) in your patch, read_info_ref would always add full name, of which first component is the type of the tag.
I am wondering if to do this like in my abovementioned patch, putting references in single string, separated by ':' (':' cannot be part of valid ref name), or use array (anonymous array reference to be more exact).
[*1*] Do you have better proposal for this name? Perhaps format_referencing_marker, or just format_marker?
---
Quoted 11 lines
# format marker of refs pointing to given object sub git_get_referencing {gitweb/gitweb.perl +2
-2- my ($refs, $id) = @_; + my ($refs, $id, $class) = @_; if (defined $refs->{$id}) { - return ' <span class="tag">' . esc_html($refs->{$id}) . '</span>'; + return " <span class=\"$class\">" . esc_html($refs->{$id}) . "</span>"; } else { return ""; }
[...]
Quoted 2 lines
gitweb/gitweb.perl +1
-1- my ($revlist, $from, $to, $refs, $extra) = @_; + my ($revlist, $from, $to, $refs, $heads, $extra) = @_;
[...]
Quoted 5 lines
gitweb/gitweb.perl +3
-2- #my $ref = defined $refs ? git_get_referencing($refs, $commit) : ''; - my $ref = git_get_referencing($refs, $commit); + #my $ref = defined $refs ? git_get_referencing($refs, $commit, "tag") : ''; + my $ref = git_get_referencing($refs, $commit, "tag"); + my $head = git_get_referencing($heads, $commit, "head");
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
Quoted 6 lines · Jakub Narebski
By the way, please do not put "Hello," in the commit message part of patch. You can put your comments (like which branch and/or commit is the batch based on) either after "---" and before the patch itself, or at the beginning and separate them from the commit message by "+++" (this separator is supported by git tools,...
???
Quoted 6 lines
I've planned on patch which does something similar to yours, but in slightly different way: instead of two calls to
git_get_referencing(format_mark_referencing[*1*] after rename) and two calls toread_info_ref(git_get_referencesafter rename) in your patch,read_info_refwould always add full name, of which first component is the type of the tag.
get_referencing to get, and format_ref to format perhaps?
Quoted 4 lines
I am wondering if to do this like in my abovementioned patch, putting references in single string, separated by ':' (':' cannot be part of valid ref name), or use array (anonymous array reference to be more exact).
Two things and half come to mind.
get_referencing could get and return the full refname without abbreviation ('heads/jn/web' or 'tags/v1.0'), and the caller can do whatever with them (e.g. see what the name begins with to tell heads and tags apart). This is probably the most flexible if we do not want to cast the categorization of refs in stone.
Otherwise, return an arrayref, like ['tag', 'v1.0', 'v1.0'] or ['head', 'web', 'jn/web'], to say what kind, short name and full name.
I've always wondered if the span that shows the short refname could have an on-hover pop-up (title attribute is often shown that way) to show the full name. Then you could do something like:
$long_name = 'heads/jn/web'; # or 'tags/v1.0'
$kind = ($long_name =~ /^heads/) ? 'head' : 'tag';
$long_name = s|^[^/]*/||;
($short_name = $long_name) =~ s|.*/||;
$long_name = esc_html($long_name);
$short_name = esc_html($short_name);
return " <span class='$kind' title='$long_name'>$short_name</span>";hoi :)
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Jakub Narebski
By the way, please do not put "Hello," in the commit message part of patch. You can put your comments (like which branch and/or commit is the batch based on) either after "---" and before the patch itself, or at the beginning and separate them from the commit message by "+++" (this separator is supported by git tools,...
???
the +++ feature has never been accepted for GIT.
Signature · 1 line
Martin Waitz
Quoted 10 lines · Junio C Hamano
Quoted 6 lines · Jakub Narebski
I've planned on patch which does something similar to yours, but in slightly different way: instead of two calls to
git_get_referencing(format_mark_referencing[*1*] after rename) and two calls toread_info_ref(git_get_referencesafter rename) in your patch,read_info_refwould always add full name, of which first component is the type of the tag.
get_referencingto get, andformat_refto format perhaps?
Thanks for a suggestion. I've decided on git_get_references, and format_ref_marker,but it isn't cast in stone.
Quoted 13 lines
Quoted 4 lines
I am wondering if to do this like in my abovementioned patch, putting references in single string, separated by ':' (':' cannot be part of valid ref name), or use array (anonymous array reference to be more exact).
Two things and half come to mind.
get_referencingcould get and return the full refname without abbreviation ('heads/jn/web' or 'tags/v1.0'), and the caller can do whatever with them (e.g. see what the name begins with to tell heads and tags apart). This is probably the most flexible if we do not want to cast the categorization of refs in stone.
Quoted 3 lines
Otherwise, return an arrayref, like ['tag', 'v1.0', 'v1.0'] or ['head', 'web', 'jn/web'], to say what kind, short name and full name.
Perhaps I have not said things clearly. The problem I meant to solve is the fact that there might be more than one ref pointing to a given object. Currently read_info_ref does not its job joining references pointing to given object (referenced object is key of a hash) using " / ", i.e. creating the "joined tag".
In dropped patch I've mentioned I joined references using ':' as it can't be part of valid ref name, then split it on ':' on formatting.
But they can be put into anonymous arrayref (e.g. ['heads/next', 'heads/autoconf'] at the start of 'autoconf' branch, or ['heads/master', 'heads/next', 'tags/v1.4.2'], not 'heads/master:heads/next:tags/v1.4.2' my patch did.
Quoted 5 lines
I've always wondered if the span that shows the short refname could have an on-hover pop-up (title attribute is often shown that way) to show the full name. Then you could do something like:
Quoted 7 lines
$long_name = 'heads/jn/web'; # or 'tags/v1.0'
$kind = ($long_name =~ /^heads/) ? 'head' : 'tag';
$long_name = s|^[^/]*/||;
($short_name = $long_name) =~ s|.*/||;
$long_name = esc_html($long_name);
$short_name = esc_html($short_name);
return " <span class='$kind' title='$long_name'>$short_name</span>";Currently (in core-git) besides 'heads' and 'tags' there might be 'remotes' (when using --use-separate-remote' option of git-clone), all following the rule of being plural (in English) to the type of tag, so one could use
$ref =~ m|(^[^/])*s?/|;
$kind = $1;for kind.
By the way, is it really usefull to have shortened ref name, e.g. 'web' for 'jn/web'? That is what gitweb does currently (only without giving ling name at all). It is probably bad practice, but I've had branches ab/sth and zz/sth, with the same shortname.
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
Quoted 4 lines · Jakub Narebski
But they can be put into anonymous arrayref (e.g. ['heads/next', 'heads/autoconf'] at the start of 'autoconf' branch, or ['heads/master', 'heads/next', 'tags/v1.4.2'], not 'heads/master:heads/next:tags/v1.4.2' my patch did.
Concatenating them with ':' into a single string, only to later split it, sounds simply stupid; I'd go for arrayref if I were you.
Quoted 4 lines
By the way, is it really usefull to have shortened ref name, e.g. 'web' for 'jn/web'? That is what gitweb does currently (only without giving ling name at all). It is probably bad practice, but I've had branches ab/sth and zz/sth, with the same shortname.
I think most people tend to use unique refs, so maybe showing the shortname by default and unique suffix when ambiguous (that would end up always showing minimal unique suffix) would be reasonable.