gitweb: More per-view navigation bar links
PATCH 1/6 gitweb: More per-view navigation bar links
Navigation bars in various views were empty or missed important items that should have been there, e.g. getting a snapshot in tree view or log of ancestry in commit view...
This feeble patch attempts to consolidate that.
---
gitweb/gitweb.perl | 42 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 38 insertions(+), 4 deletions(-)
gitweb/gitweb.perl +38 -4
@@ -2444,6 +2444,9 @@ sub git_blame2 { $cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, "blob") . " | " . + $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, + "history") . + " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head"); git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -2510,6 +2513,9 @@ sub git_blame { $cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, "blob") . " | " . + $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, + "history") . + " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, "head"); git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -2685,6 +2691,10 @@ sub git_blob { " | "; } $formats_nav .= + $cgi->a({-href => href(action=>"history", hash_base=>$hash_base, + hash=>$hash, file_name=>$file_name)}, + "history") . + " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$hash, file_name=>$file_name)}, "plain") .
@@ -2720,6 +2730,9 @@ sub git_blob { } sub git_tree { + my ($ctype, $suffix, $command) = gitweb_check_feature('snapshot'); + my $have_snapshot = (defined $ctype && defined $suffix); + if (!defined $hash) { $hash = git_get_head_hash($project); if (defined $file_name) {
@@ -2743,7 +2756,23 @@ sub git_tree { my $base = ""; my ($have_blame) = gitweb_check_feature('blame'); if (defined $hash_base && (my %co = parse_commit($hash_base))) { - git_print_page_nav('tree','', $hash_base); + my @views_nav = (); + if (defined $file_name) { + push @views_nav, + $cgi->a({-href => href(action=>"history", hash_base=>$hash_base, + hash=>$hash, file_name=>$file_name)}, + "history"), + $cgi->a({-href => href(action=>"tree", + hash_base=>"HEAD", file_name=>$file_name)}, + "head"); + } + if ($have_snapshot) { + # FIXME: Should be available when we have no hash base as well. + push @views_nav, + $cgi->a({-href => href(action=>"snapshot")}, + "snapshot"); + } + git_print_page_nav('tree','', $hash_base, undef, undef, join(' | ', @views_nav)); git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base); } else { undef $hash_base;
@@ -2888,17 +2917,22 @@ sub git_commit { my ($ctype, $suffix, $command) = gitweb_check_feature('snapshot'); my $have_snapshot = (defined $ctype && defined $suffix); - my $formats_nav = ''; + my @views_nav = (); if (defined $file_name && defined $co{'parent'}) { my $parent = $co{'parent'}; - $formats_nav .= + push @views_nav, $cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)}, "blame"); } + if (defined $co{'parent'}) { + push @views_nav, + $cgi->a({-href => href(action=>"shortlog", hash=>$hash)}, "shortlog"), + $cgi->a({-href => href(action=>"log", hash=>$hash)}, "log"); + } git_header_html(undef, $expires); git_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff', $hash, $co{'tree'}, $hash, - $formats_nav); + join (' | ', @views_nav)); if (defined $co{'parent'}) { git_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
PATCH 2/6 gitweb: Link to tree instead of snapshot in shortlog
---
gitweb/gitweb.perl | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
gitweb/gitweb.perl +2 -7
@@ -1976,9 +1976,6 @@ sub git_shortlog_body { # uses global variable $project my ($revlist, $from, $to, $refs, $extra) = @_; - my ($ctype, $suffix, $command) = gitweb_check_feature('snapshot'); - my $have_snapshot = (defined $ctype && defined $suffix); - $from = 0 unless defined $from; $to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
@@ -2004,10 +2001,8 @@ sub git_shortlog_body { print "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " . - $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff"); - if ($have_snapshot) { - print " | " . $cgi->a({-href => href(action=>"snapshot", hash=>$commit)}, "snapshot"); - } + $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " . + $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree"); print "</td>\n" . "</tr>\n"; }
PATCH 3/6 gitweb: Link to latest tree from the head line in heads list
In reply to Petr Baudis---
gitweb/gitweb.perl | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +2 -1
@@ -2164,7 +2164,8 @@ sub git_heads_body { "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => href(action=>"shortlog", hash=>$tag{'name'})}, "shortlog") . " | " . - $cgi->a({-href => href(action=>"log", hash=>$tag{'name'})}, "log") . + $cgi->a({-href => href(action=>"log", hash=>$tag{'name'})}, "log") . " | " . + $cgi->a({-href => href(action=>"tree", hash=>$tag{'name'}, hash_base=>$tag{'name'})}, "tree") . "</td>\n" . "</tr>"; }
PATCH 4/6 gitweb: Link to associated tree from a particular log item in full log view
In reply to Petr Baudis---
gitweb/gitweb.perl | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +2 -0
@@ -2873,6 +2873,8 @@ sub git_log { $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . + " | " . + $cgi->a({-href => href(action=>"tree", hash=>$commit), hash_base=>$commit}, "tree") . "<br/>\n" . "</div>\n" . "<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
Re: [PATCH 4/6] gitweb: Link to associated tree from a particular log item in full log view
I presume you are running this version at repo.or.cz, but
(1) go to http://repo.or.cz/?p=stgit.git;a=log
(2) pick "tree" of one of the commits
(3) go browser-back, then pick "tree" from the top navbar
The resulting tree view of (2) lacks navbar while (3) looks much saner.
You do not have the tree object name available in git_log to generate an URL with both h and hb, and getting to it is an extra work.
This would fix this particular breakage.
gitweb/gitweb.perl +3 -3
@@ -2732,9 +2732,9 @@ sub git_tree { my $base = $hash_base || $hash; $hash = git_get_hash_by_path($base, $file_name, "tree"); } - if (!defined $hash_base) { - $hash_base = $hash; - } + } + if (!defined $hash_base) { + $hash_base = $hash; } $/ = "\0"; open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
Re: [PATCH 4/6] gitweb: Link to associated tree from a particular log item in full log view
Dear diary, on Fri, Sep 22, 2006 at 06:18:09AM CEST, I got a letter where Junio C Hamano <[email protected]> said that...
Quoted 8 lines
I presume you are running this version at repo.or.cz, but
(1) go to http://repo.or.cz/?p=stgit.git;a=log
(2) pick "tree" of one of the commits
(3) go browser-back, then pick "tree" from the top navbarThe resulting tree view of (2) lacks navbar while (3) looks much saner.
Oops. It's trivial typo:
gitweb/gitweb.perl +1 -1
@@ -2880,7 +2880,7 @@ sub git_log { " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " . - $cgi->a({-href => href(action=>"tree", hash=>$commit), hash_base=>$commit}, "tree") . + $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree") . "<br/>\n" . "</div>\n" . "<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
Quoted 3 lines
You do not have the tree object name available in
git_logto generate an URL with both h and hb, and getting to it is an extra work.
Well using commit hash as a tree id works just fine...
Quoted 1 line
This would fix this particular breakage.
My knowledge of gitweb.perl innards isn't good enough for me to safely ack/nak a change such deep down the chain.
Signature · 5 lines
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)Re: [PATCH 4/6] gitweb: Link to associated tree from a particular log item in full log view
Quoted 16 lines · Petr Baudis
Oops. It's trivial typo:
gitweb/gitweb.perl +1
-1@@ -2880,7 +2880,7 @@ sub git_log { " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " . - $cgi->a({-href => href(action=>"tree", hash=>$commit), hash_base=>$commit}, "tree") . + $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree") . "<br/>\n" . "</div>\n" . "<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
Quoted 5 lines
Quoted 3 lines
You do not have the tree object name available in
git_logto generate an URL with both h and hb, and getting to it is an extra work.Well using commit hash as a tree id works just fine...
I agree that change is much safer. Will apply with an appropriate log message and attribution. No need to resend.
Re: [PATCH 4/6] gitweb: Link to associated tree from a particular log item in full log view
Quoted 18 lines · Junio C Hamano
Quoted 16 lines · Petr Baudis
Oops. It's trivial typo:
gitweb/gitweb.perl +1
-1@@ -2880,7 +2880,7 @@ sub git_log { " | " . $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") . " | " . - $cgi->a({-href => href(action=>"tree", hash=>$commit), hash_base=>$commit}, "tree") . + $cgi->a({-href => href(action=>"tree", hash=>$commit, hash_base=>$commit)}, "tree") . "<br/>\n" . "</div>\n" . "<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
You do not have the tree object name available in
git_logto generate an URL with both h and hb, and getting to it is an extra work.Well using commit hash as a tree id works just fine...
I agree that change is much safer. Will apply with an appropriate log message and attribution. No need to resend.
I think that hash_base without hash should be enough. But I'm not sure if it is. Well, commit hash is tree-ish...
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
PATCH 5/6 gitweb: Rename "plain" labels to "raw"
In reply to Petr BaudisI don't have much preference either way and as far as I'm concerned, it may go the other way as well. Consistency is what is important.
---
gitweb/gitweb.perl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
gitweb/gitweb.perl +4 -4
@@ -2693,14 +2693,14 @@ sub git_blob { " | " . $cgi->a({-href => href(action=>"blob_plain", hash=>$hash, file_name=>$file_name)}, - "plain") . + "raw") . " | " . $cgi->a({-href => href(action=>"blob", hash_base=>"HEAD", file_name=>$file_name)}, "head"); } else { $formats_nav .= - $cgi->a({-href => href(action=>"blob_plain", hash=>$hash)}, "plain"); + $cgi->a({-href => href(action=>"blob_plain", hash=>$hash)}, "raw"); } git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav); git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
@@ -3109,7 +3109,7 @@ sub git_blobdiff { hash=>$hash, hash_parent=>$hash_parent, hash_base=>$hash_base, hash_parent_base=>$hash_parent_base, file_name=>$file_name, file_parent=>$file_parent)}, - "plain"); + "raw"); git_header_html(undef, $expires); if (defined $hash_base && (my %co = parse_commit($hash_base))) { git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
@@ -3212,7 +3212,7 @@ sub git_commitdiff { my $formats_nav = $cgi->a({-href => href(action=>"commitdiff_plain", hash=>$hash, hash_parent=>$hash_parent)}, - "plain"); + "raw"); git_header_html(undef, $expires); git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
Re: [PATCH 5/6] gitweb: Rename "plain" labels to "raw"
Quoted 2 lines · Petr Baudis
I don't have much preference either way and as far as I'm concerned, it may go the other way as well. Consistency is what is important.
"raw" link was introduced in 25b7c18ecd9779158cb1c02572396bab22c6e0cf by Luben Tuikov. I'd rather use "plain"...
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git
Re: [PATCH 5/6] gitweb: Rename "plain" labels to "raw"
Dear diary, on Fri, Sep 22, 2006 at 11:04:49AM CEST, I got a letter where Jakub Narebski <[email protected]> said that...
Quoted 7 lines
Quoted 2 lines · Petr Baudis
I don't have much preference either way and as far as I'm concerned, it may go the other way as well. Consistency is what is important.
"raw" link was introduced in
25b7c18ecd9779158cb1c02572396bab22c6e0cfby Luben Tuikov. I'd rather use "plain"...
I kind of like "raw" more because it's IMHO more obvious what it exactly is (it could also mean some stripped-down HTML or whatever otherwise) and is more appropriate for things that actually are not plaintext, like pictures.
Signature · 5 lines
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)PATCH 6/6 gitweb: Relabel "head" as "HEAD"
In reply to Petr Baudis"head" is a reference in refs/heads/, while those labels mean HEAD, the latest revision of the default branch.
---
gitweb/gitweb.perl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
gitweb/gitweb.perl +4 -4
@@ -2444,7 +2444,7 @@ sub git_blame2 { "history") . " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, - "head"); + "HEAD"); git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav); git_print_header_div('commit', esc_html($co{'title'}), $hash_base); git_print_page_path($file_name, $ftype, $hash_base);
@@ -2513,7 +2513,7 @@ sub git_blame { "history") . " | " . $cgi->a({-href => href(action=>"blame", file_name=>$file_name)}, - "head"); + "HEAD"); git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav); git_print_header_div('commit', esc_html($co{'title'}), $hash_base); git_print_page_path($file_name, 'blob', $hash_base);
@@ -2697,7 +2697,7 @@ sub git_blob { " | " . $cgi->a({-href => href(action=>"blob", hash_base=>"HEAD", file_name=>$file_name)}, - "head"); + "HEAD"); } else { $formats_nav .= $cgi->a({-href => href(action=>"blob_plain", hash=>$hash)}, "raw");
@@ -2760,7 +2760,7 @@ sub git_tree { "history"), $cgi->a({-href => href(action=>"tree", hash_base=>"HEAD", file_name=>$file_name)}, - "head"); + "HEAD"), } if ($have_snapshot) { # FIXME: Should be available when we have no hash base as well.