{"thread":{"id":"43744","subject":"[PATCH] gitweb: Add \"next\" link to commit view","startedAt":"2006-12-15T20:57:16Z","lastAt":"2006-12-15T20:57:16Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297676","messageId":"11662162364166-git-send-email-jnareb@gmail.com","threadId":"43744","inReplyTo":null,"subject":"[PATCH] gitweb: Add \"next\" link to commit view","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-15T20:57:16Z","receivedAt":"2006-12-15T20:57:16Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add a kind of \"next\" view in the bottom part of navigation bar for\n\"commit\" view, similar to what was added for \"commitdiff\" view in\ncommit 151602df00b8e5c5b4a8193f59a94b85f9b5aebc\n  'gitweb: Add \"next\" link to commitdiff view'\n\nFor \"commit\" view for single parent commit:\n  (parent: _commit_)\nFor \"commit\" view for merge (multi-parent) commit:\n  (merge: _commit_ _commit_ ...)\nFor \"commit\" view for root (parentless) commit\n  (initial)\nwhere _link_ denotes hyperlink.  SHA1 of commit is shortened\nto 7 characters on display.\n\nWhile at it, remove leftovers from commit cae1862a by Petr Baudis:\n  'gitweb: More per-view navigation bar links'\nnamely the \"blame\" link if there exist $file_name and commit has a\nparent; it was added in git_commit probably by mistake.  The rest\nof what mentioned commit added for git_commit was removed in\ncommit 6e0e92fda893311ff5af91836e5007bf6bbd4a21 by Luben Tuikov:\n  'gitweb: Do not print \"log\" and \"shortlog\" redundantly in commit view'\n(which should have probably removed also this \"blame\" link removed now).\n\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nBy the way, the history shown above was found using git 'pickaxe',\nnamely\n  $ git log -p -S'my @views_nav = ();' -- gitweb/\nwhich found the first commit. I have noticed that some parts of\nwhat this patch added to git_commit were removed later:\n  $ git log -p -S'push @views_nav,' -- gitweb/\nfound the second commit mentioned.\n\nThe first part could be found also by git-blame command (or\nany other annotate/blame command in any other SCM), but to\nnotice the second...\n\n\n gitweb/gitweb.perl |   38 +++++++++++++++++++++++++++++---------\n 1 files changed, 29 insertions(+), 9 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex ebf35a1..902c514 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3571,8 +3571,34 @@ sub git_commit {\n \tmy %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});\n \tmy %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});\n \n-\tmy $parent = $co{'parent'};\n-\tmy $parents = $co{'parents'};\n+\tmy $parent  = $co{'parent'};\n+\tmy $parents = $co{'parents'}; # listref\n+\n+\t# we need to prepare $formats_nav before any parameter munging\n+\tmy $formats_nav;\n+\tif (!defined $parent) {\n+\t\t# --root commitdiff\n+\t\t$formats_nav .= '(initial)';\n+\t} elsif (@$parents == 1) {\n+\t\t# single parent commit\n+\t\t$formats_nav .=\n+\t\t\t'(parent: ' .\n+\t\t\t$cgi->a({-href => href(action=>\"commit\",\n+\t\t\t                       hash=>$parent)},\n+\t\t\t        esc_html(substr($parent, 0, 7))) .\n+\t\t\t')';\n+\t} else {\n+\t\t# merge commit\n+\t\t$formats_nav .=\n+\t\t\t'(merge: ' .\n+\t\t\tjoin(' ', map {\n+\t\t\t\t$cgi->a({-href => href(action=>\"commitdiff\",\n+\t\t\t\t                       hash=>$_)},\n+\t\t\t\t        esc_html(substr($_, 0, 7)));\n+\t\t\t} @$parents ) .\n+\t\t\t')';\n+\t}\n+\n \tif (!defined $parent) {\n \t\t$parent = \"--root\";\n \t}\n@@ -3596,16 +3622,10 @@ sub git_commit {\n \n \tmy $have_snapshot = gitweb_have_snapshot();\n \n-\tmy @views_nav = ();\n-\tif (defined $file_name && defined $co{'parent'}) {\n-\t\tpush @views_nav,\n-\t\t\t$cgi->a({-href => href(action=>\"blame\", hash_parent=>$parent, file_name=>$file_name)},\n-\t\t\t        \"blame\");\n-\t}\n \tgit_header_html(undef, $expires);\n \tgit_print_page_nav('commit', '',\n \t                   $hash, $co{'tree'}, $hash,\n-\t                   join (' | ', @views_nav));\n+\t                   $formats_nav);\n \n \tif (defined $co{'parent'}) {\n \t\tgit_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);\n-- \n1.4.4.1\n"}]}