{"thread":{"id":"43329","subject":"[PATCH 1/5] gitweb: Protect against possible warning in git_commitdiff","startedAt":"2006-11-18T22:35:37Z","lastAt":"2006-11-18T22:38:42Z","messageCount":7,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"296190","messageId":"1163889342877-git-send-email-jnareb@gmail.com","threadId":"43329","inReplyTo":null,"subject":"[PATCH 0/5] gitweb: New patchset view corrections and improvements, and few other things","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:35:37Z","receivedAt":"2006-11-18T22:35:37Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Table of contents:\n [PATCH 1/5] gitweb: Protect against possible warning in git_commitdiff\n [PATCH 2/5] gitweb: Buffer diff header to deal with split patches \n                     + git_patchset_body refactoring\n [PATCH 3/5] gitweb: New improved formatting of chunk header in diff\n [PATCH 4/5] gitweb: Default to $hash_base or HEAD for $hash\n                     in \"commit\" and \"commitdiff\"\n [PATCH 5/5] gitweb: Add an option to href() to return full URL\n\nDiffstat:\n gitweb/gitweb.css  |   13 +++\n gitweb/gitweb.perl |  264 ++++++++++++++++++++++++++++++++--------------------\n 2 files changed, 176 insertions(+), 101 deletions(-)\n\n-- \nJakub Narebski\n"},{"id":"294378","messageId":"11638893431855-git-send-email-jnareb@gmail.com","threadId":"43329","inReplyTo":"1163889342877-git-send-email-jnareb@gmail.com","subject":"[PATCH 1/5] gitweb: Protect against possible warning in git_commitdiff","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:35:38Z","receivedAt":"2006-11-18T22:35:38Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nI'm not sure _when_ this eror (warning) occur, as it happened to me\nonce, but I couldn't repeat it; but I didn't try too hard.\n\nI think it is better coding practice, and more readable.\n\n gitweb/gitweb.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 7587595..b2482fe 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3731,7 +3731,8 @@ sub git_commitdiff {\n \t\t\t$hash_parent, $hash, \"--\"\n \t\t\tor die_error(undef, \"Open git-diff-tree failed\");\n \n-\t\twhile (chomp(my $line = <$fd>)) {\n+\t\twhile (my $line = <$fd>) {\n+\t\t\tchomp $line;\n \t\t\t# empty line ends raw part of diff-tree output\n \t\t\tlast unless $line;\n \t\t\tpush @difftree, $line;\n-- \n1.4.3.4\n"},{"id":"297022","messageId":"1163889344537-git-send-email-jnareb@gmail.com","threadId":"43329","inReplyTo":"1163889342877-git-send-email-jnareb@gmail.com","subject":"[PATCH 2/5] gitweb: Buffer diff header to deal with split patches + git_patchset_body refactoring","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:35:39Z","receivedAt":"2006-11-18T22:35:39Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"There are some cases when one line from \"raw\" git-diff output (raw format)\ncorresponds to more than one patch in the patchset git-diff output. To deal\nwith this buffer git diff header and extended diff header (everything up to\nactual patch) to check from information from \"index <hash>..<hash>\" extended\nheader line if the patch corresponds to the same or next difftree raw line.\n\nThis could also be used to gather information needed for hyperlinking, and\nused for printing gitweb quoted filenames, from extended diff header instead\nof raw git-diff output.\n\nWhile at it, refactor git_patchset_body subroutine from the event-driven,\nAWK-like state-machine parsing to sequential parsing: for each patch\nparse (and output) git diff header, parse extended diff header, parse two-line\nfrom-file/to-file diff header, parse patch itself; patch ends with the end\nof input [file] or the line matching m/^diff /.\n\nFor better understanding the code, there were added assertions in the\ncomments a la Carp::Assert module. Just in case there is commented out code\ndealing with unexpected end of input (should not happen, hence commented\nout).\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nWhile starting to write buffering part of this patch I have realized\nthat git_patchset_body needs refactoring. I think it is now much more\nreadable, at least for people who know the patch format.\n\n gitweb/gitweb.perl |  235 ++++++++++++++++++++++++++++++----------------------\n 1 files changed, 136 insertions(+), 99 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b2482fe..bf58c3b 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2202,31 +2202,56 @@ sub git_patchset_body {\n \tmy ($fd, $difftree, $hash, $hash_parent) = @_;\n \n \tmy $patch_idx = 0;\n-\tmy $in_header = 0;\n-\tmy $patch_found = 0;\n+\tmy $patch_line;\n \tmy $diffinfo;\n \tmy (%from, %to);\n+\tmy ($from_id, $to_id);\n \n \tprint \"<div class=\\\"patchset\\\">\\n\";\n \n-\tLINE:\n-\twhile (my $patch_line = <$fd>) {\n+\t# skip to first patch\n+\twhile ($patch_line = <$fd>) {\n \t\tchomp $patch_line;\n \n-\t\tif ($patch_line =~ m/^diff /) { # \"git diff\" header\n-\t\t\t# beginning of patch (in patchset)\n-\t\t\tif ($patch_found) {\n-\t\t\t\t# close extended header for previous empty patch\n-\t\t\t\tif ($in_header) {\n-\t\t\t\t\tprint \"</div>\\n\" # class=\"diff extended_header\"\n-\t\t\t\t}\n-\t\t\t\t# close previous patch\n-\t\t\t\tprint \"</div>\\n\"; # class=\"patch\"\n-\t\t\t} else {\n-\t\t\t\t# first patch in patchset\n-\t\t\t\t$patch_found = 1;\n+\t\tlast if ($patch_line =~ m/^diff /);\n+\t}\n+\n+ PATCH:\n+\twhile ($patch_line) {\n+\t\tmy @diff_header;\n+\n+\t\t# git diff header\n+\t\t#assert($patch_line =~ m/^diff /) if DEBUG;\n+\t\t#assert($patch_line !~ m!$/$!) if DEBUG; # is chomp-ed\n+\t\tpush @diff_header, $patch_line;\n+\n+\t\t# extended diff header\n+\tEXTENDED_HEADER:\n+\t\twhile ($patch_line = <$fd>) {\n+\t\t\tchomp $patch_line;\n+\n+\t\t\tlast EXTENDED_HEADER if ($patch_line =~ m/^--- /);\n+\n+\t\t\tif ($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/) {\n+\t\t\t\t$from_id = $1;\n+\t\t\t\t$to_id   = $2;\n \t\t\t}\n-\t\t\tprint \"<div class=\\\"patch\\\" id=\\\"patch\". ($patch_idx+1) .\"\\\">\\n\";\n+\n+\t\t\tpush @diff_header, $patch_line;\n+\t\t}\n+\t\t#last PATCH unless $patch_line;\n+\t\tmy $last_patch_line = $patch_line;\n+\n+\t\t# check if current patch belong to current raw line\n+\t\t# and parse raw git-diff line if needed\n+\t\tif (defined $diffinfo &&\n+\t\t    $diffinfo->{'from_id'} eq $from_id &&\n+\t\t    $diffinfo->{'to_id'}   eq $to_id) {\n+\t\t\t# this is split patch\n+\t\t\tprint \"<div class=\\\"patch cont\\\">\\n\";\n+\t\t} else {\n+\t\t\t# advance raw git-diff output if needed\n+\t\t\t$patch_idx++ if defined $diffinfo;\n \n \t\t\t# read and prepare patch information\n \t\t\tif (ref($difftree->[$patch_idx]) eq \"HASH\") {\n@@ -2247,100 +2272,112 @@ sub git_patchset_body {\n \t\t\t\t                   hash=>$diffinfo->{'to_id'},\n \t\t\t\t                   file_name=>$to{'file'});\n \t\t\t}\n-\t\t\t$patch_idx++;\n-\n-\t\t\t# print \"git diff\" header\n-\t\t\t$patch_line =~ s!^(diff (.*?) )\"?a/.*$!$1!;\n-\t\t\tif ($from{'href'}) {\n-\t\t\t\t$patch_line .= $cgi->a({-href => $from{'href'}, -class => \"path\"},\n-\t\t\t\t                       'a/' . esc_path($from{'file'}));\n-\t\t\t} else { # file was added\n-\t\t\t\t$patch_line .= 'a/' . esc_path($from{'file'});\n-\t\t\t}\n-\t\t\t$patch_line .= ' ';\n-\t\t\tif ($to{'href'}) {\n-\t\t\t\t$patch_line .= $cgi->a({-href => $to{'href'}, -class => \"path\"},\n-\t\t\t\t                       'b/' . esc_path($to{'file'}));\n-\t\t\t} else { # file was deleted\n-\t\t\t\t$patch_line .= 'b/' . esc_path($to{'file'});\n-\t\t\t}\n-\n-\t\t\tprint \"<div class=\\\"diff header\\\">$patch_line</div>\\n\";\n-\t\t\tprint \"<div class=\\\"diff extended_header\\\">\\n\";\n-\t\t\t$in_header = 1;\n-\t\t\tnext LINE;\n+\t\t\t# this is first patch for raw difftree line with $patch_idx index\n+\t\t\t# we index @$difftree array from 0, but number patches from 1\n+\t\t\tprint \"<div class=\\\"patch\\\" id=\\\"patch\". ($patch_idx+1) .\"\\\">\\n\";\n \t\t}\n \n-\t\tif ($in_header) {\n-\t\t\tif ($patch_line !~ m/^---/) {\n-\t\t\t\t# match <path>\n-\t\t\t\tif ($patch_line =~ s!^((copy|rename) from ).*$!$1! && $from{'href'}) {\n-\t\t\t\t\t$patch_line .= $cgi->a({-href=>$from{'href'}, -class=>\"path\"},\n-\t\t\t\t\t                        esc_path($from{'file'}));\n-\t\t\t\t}\n-\t\t\t\tif ($patch_line =~ s!^((copy|rename) to ).*$!$1! && $to{'href'}) {\n-\t\t\t\t\t$patch_line = $cgi->a({-href=>$to{'href'}, -class=>\"path\"},\n-\t\t\t\t\t                      esc_path($to{'file'}));\n-\t\t\t\t}\n-\t\t\t\t# match <mode>\n-\t\t\t\tif ($patch_line =~ m/\\s(\\d{6})$/) {\n-\t\t\t\t\t$patch_line .= '<span class=\"info\"> (' .\n-\t\t\t\t\t               file_type_long($1) .\n-\t\t\t\t\t               ')</span>';\n+\t\t# print \"git diff\" header\n+\t\t$patch_line = shift @diff_header;\n+\t\t$patch_line =~ s!^(diff (.*?) )\"?a/.*$!$1!;\n+\t\tif ($from{'href'}) {\n+\t\t\t$patch_line .= $cgi->a({-href => $from{'href'}, -class => \"path\"},\n+\t\t\t                       'a/' . esc_path($from{'file'}));\n+\t\t} else { # file was added\n+\t\t\t$patch_line .= 'a/' . esc_path($from{'file'});\n+\t\t}\n+\t\t$patch_line .= ' ';\n+\t\tif ($to{'href'}) {\n+\t\t\t$patch_line .= $cgi->a({-href => $to{'href'}, -class => \"path\"},\n+\t\t\t                       'b/' . esc_path($to{'file'}));\n+\t\t} else { # file was deleted\n+\t\t\t$patch_line .= 'b/' . esc_path($to{'file'});\n+\t\t}\n+\t\tprint \"<div class=\\\"diff header\\\">$patch_line</div>\\n\";\n+\n+\t\t# print extended diff header\n+\t\tprint \"<div class=\\\"diff extended_header\\\">\\n\" if (@diff_header > 0);\n+\tEXTENDED_HEADER:\n+\t\tforeach $patch_line (@diff_header) {\n+\t\t\t# match <path>\n+\t\t\tif ($patch_line =~ s!^((copy|rename) from ).*$!$1! && $from{'href'}) {\n+\t\t\t\t$patch_line .= $cgi->a({-href=>$from{'href'}, -class=>\"path\"},\n+\t\t\t\t                        esc_path($from{'file'}));\n+\t\t\t}\n+\t\t\tif ($patch_line =~ s!^((copy|rename) to ).*$!$1! && $to{'href'}) {\n+\t\t\t\t$patch_line = $cgi->a({-href=>$to{'href'}, -class=>\"path\"},\n+\t\t\t\t                      esc_path($to{'file'}));\n+\t\t\t}\n+\t\t\t# match <mode>\n+\t\t\tif ($patch_line =~ m/\\s(\\d{6})$/) {\n+\t\t\t\t$patch_line .= '<span class=\"info\"> (' .\n+\t\t\t\t               file_type_long($1) .\n+\t\t\t\t               ')</span>';\n+\t\t\t}\n+\t\t\t# match <hash>\n+\t\t\tif ($patch_line =~ m/^index/) {\n+\t\t\t\tmy ($from_link, $to_link);\n+\t\t\t\tif ($from{'href'}) {\n+\t\t\t\t\t$from_link = $cgi->a({-href=>$from{'href'}, -class=>\"hash\"},\n+\t\t\t\t\t                     substr($diffinfo->{'from_id'},0,7));\n+\t\t\t\t} else {\n+\t\t\t\t\t$from_link = '0' x 7;\n \t\t\t\t}\n-\t\t\t\t# match <hash>\n-\t\t\t\tif ($patch_line =~ m/^index/) {\n-\t\t\t\t\tmy ($from_link, $to_link);\n-\t\t\t\t\tif ($from{'href'}) {\n-\t\t\t\t\t\t$from_link = $cgi->a({-href=>$from{'href'}, -class=>\"hash\"},\n-\t\t\t\t\t\t                     substr($diffinfo->{'from_id'},0,7));\n-\t\t\t\t\t} else {\n-\t\t\t\t\t\t$from_link = '0' x 7;\n-\t\t\t\t\t}\n-\t\t\t\t\tif ($to{'href'}) {\n-\t\t\t\t\t\t$to_link = $cgi->a({-href=>$to{'href'}, -class=>\"hash\"},\n-\t\t\t\t\t\t                   substr($diffinfo->{'to_id'},0,7));\n-\t\t\t\t\t} else {\n-\t\t\t\t\t\t$to_link = '0' x 7;\n-\t\t\t\t\t}\n-\t\t\t\t\tmy ($from_id, $to_id) = ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});\n-\t\t\t\t\t$patch_line =~ s!$from_id\\.\\.$to_id!$from_link..$to_link!;\n+\t\t\t\tif ($to{'href'}) {\n+\t\t\t\t\t$to_link = $cgi->a({-href=>$to{'href'}, -class=>\"hash\"},\n+\t\t\t\t\t                   substr($diffinfo->{'to_id'},0,7));\n+\t\t\t\t} else {\n+\t\t\t\t\t$to_link = '0' x 7;\n \t\t\t\t}\n-\t\t\t\tprint $patch_line . \"<br/>\\n\";\n-\n-\t\t\t} else {\n-\t\t\t\t#$in_header && $patch_line =~ m/^---/;\n-\t\t\t\tprint \"</div>\\n\"; # class=\"diff extended_header\"\n-\t\t\t\t$in_header = 0;\n+\t\t\t\t#affirm {\n+\t\t\t\t#\tmy ($from_hash, $to_hash) =\n+\t\t\t\t#\t\t($patch_line =~ m/^index ([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/);\n+\t\t\t\t#\tmy ($from_id, $to_id) =\n+\t\t\t\t#\t\t($diffinfo->{'from_id'}, $diffinfo->{'to_id'});\n+\t\t\t\t#\t($from_hash eq $from_id) && ($to_hash eq $to_id);\n+\t\t\t\t#} if DEBUG;\n+\t\t\t\tmy ($from_id, $to_id) = ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});\n+\t\t\t\t$patch_line =~ s!$from_id\\.\\.$to_id!$from_link..$to_link!;\n+\t\t\t}\n+\t\t\tprint $patch_line . \"<br/>\\n\";\n+\t\t}\n+\t\tprint \"</div>\\n\"  if (@diff_header > 0); # class=\"diff extended_header\"\n+\n+\t\t# from-file/to-file diff header\n+\t\t$patch_line = $last_patch_line;\n+\t\t#assert($patch_line =~ m/^---/) if DEBUG;\n+\t\tif ($from{'href'}) {\n+\t\t\t$patch_line = '--- a/' .\n+\t\t\t              $cgi->a({-href=>$from{'href'}, -class=>\"path\"},\n+\t\t\t                      esc_path($from{'file'}));\n+\t\t}\n+\t\tprint \"<div class=\\\"diff from_file\\\">$patch_line</div>\\n\";\n \n-\t\t\t\tif ($from{'href'}) {\n-\t\t\t\t\t$patch_line = '--- a/' .\n-\t\t\t\t\t              $cgi->a({-href=>$from{'href'}, -class=>\"path\"},\n-\t\t\t\t\t                      esc_path($from{'file'}));\n-\t\t\t\t}\n-\t\t\t\tprint \"<div class=\\\"diff from_file\\\">$patch_line</div>\\n\";\n+\t\t$patch_line = <$fd>;\n+\t\t#last PATCH unless $patch_line;\n+\t\tchomp $patch_line;\n \n-\t\t\t\t$patch_line = <$fd>;\n-\t\t\t\tchomp $patch_line;\n+\t\t#assert($patch_line =~ m/^+++/) if DEBUG;\n+\t\tif ($to{'href'}) {\n+\t\t\t$patch_line = '+++ b/' .\n+\t\t\t              $cgi->a({-href=>$to{'href'}, -class=>\"path\"},\n+\t\t\t                      esc_path($to{'file'}));\n+\t\t}\n+\t\tprint \"<div class=\\\"diff to_file\\\">$patch_line</div>\\n\";\n \n-\t\t\t\t#$patch_line =~ m/^+++/;\n-\t\t\t\tif ($to{'href'}) {\n-\t\t\t\t\t$patch_line = '+++ b/' .\n-\t\t\t\t\t              $cgi->a({-href=>$to{'href'}, -class=>\"path\"},\n-\t\t\t\t\t                      esc_path($to{'file'}));\n-\t\t\t\t}\n-\t\t\t\tprint \"<div class=\\\"diff to_file\\\">$patch_line</div>\\n\";\n+\t\t# the patch itself\n+\tLINE:\n+\t\twhile ($patch_line = <$fd>) {\n+\t\t\tchomp $patch_line;\n \n-\t\t\t}\n+\t\t\tnext PATCH if ($patch_line =~ m/^diff /);\n \n-\t\t\tnext LINE;\n+\t\t\tprint format_diff_line($patch_line);\n \t\t}\n \n-\t\tprint format_diff_line($patch_line);\n+\t} continue {\n+\t\tprint \"</div>\\n\"; # class=\"patch\"\n \t}\n-\tprint \"</div>\\n\" if $in_header; # extended header\n-\n-\tprint \"</div>\\n\" if $patch_found; # class=\"patch\"\n \n \tprint \"</div>\\n\"; # class=\"patchset\"\n }\n-- \n1.4.3.4\n"},{"id":"297419","messageId":"1163889345640-git-send-email-jnareb@gmail.com","threadId":"43329","inReplyTo":"1163889342877-git-send-email-jnareb@gmail.com","subject":"[PATCH 3/5] gitweb: New improved formatting of chunk header in diff","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:35:40Z","receivedAt":"2006-11-18T22:35:40Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"If we have provided enough info, and diff is not combined diff,\nand if provided diff line is chunk header, then:\n* split chunk header into .chunk_info and .section span elements,\n  first containing proper chunk header, second section heading\n  (aka. which function), for separate styling: the proper chunk\n  header is on non-white background, section heading part uses\n  slightly lighter color.\n* hyperlink from-file-range to starting line of from-file, if file\n  was not created.\n* hyperlink to-file-range to starting line of to-file, if file\n  was not deleted.\nLinks are of invisible variety (and \"list\" class).\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis version deals correctly with hunks of form \"@@ -n +m,l @@\" and\nfriends. The number of lines in from/to part ($from_lines/$to_lines\nvariables) is not used.\n\n gitweb/gitweb.css  |   13 +++++++++++++\n gitweb/gitweb.perl |   23 ++++++++++++++++++++++-\n 2 files changed, 35 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.css b/gitweb/gitweb.css\nindex 974b47f..7177c6e 100644\n--- a/gitweb/gitweb.css\n+++ b/gitweb/gitweb.css\n@@ -334,11 +334,13 @@ div.diff.extended_header {\n \tpadding: 2px 0px 2px 0px;\n }\n \n+div.diff a.list,\n div.diff a.path,\n div.diff a.hash {\n \ttext-decoration: none;\n }\n \n+div.diff a.list:hover,\n div.diff a.path:hover,\n div.diff a.hash:hover {\n \ttext-decoration: underline;\n@@ -362,14 +364,25 @@ div.diff.rem {\n \tcolor: #cc0000;\n }\n \n+div.diff.chunk_header a,\n div.diff.chunk_header {\n \tcolor: #990099;\n+}\n \n+div.diff.chunk_header {\n \tborder: dotted #ffe0ff;\n \tborder-width: 1px 0px 0px 0px;\n \tmargin-top: 2px;\n }\n \n+div.diff.chunk_header span.chunk_info {\n+\tbackground-color: #ffeeff;\n+}\n+\n+div.diff.chunk_header span.section {\n+\tcolor: #aa22aa;\n+}\n+\n div.diff.incomplete {\n \tcolor: #cccccc;\n }\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex bf58c3b..eadaa31 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -874,8 +874,10 @@ sub format_subject_html {\n \t}\n }\n \n+# format patch (diff) line (rather not to be used for diff headers)\n sub format_diff_line {\n \tmy $line = shift;\n+\tmy ($from, $to) = @_;\n \tmy $char = substr($line, 0, 1);\n \tmy $diff_class = \"\";\n \n@@ -891,6 +893,25 @@ sub format_diff_line {\n \t\t$diff_class = \" incomplete\";\n \t}\n \t$line = untabify($line);\n+\tif ($from && $to && $line =~ m/^\\@{2} /) {\n+\t\tmy ($from_text, $from_start, $from_lines, $to_text, $to_start, $to_lines, $section) =\n+\t\t\t$line =~ m/^\\@{2} (-(\\d+)(?:,(\\d+))?) (\\+(\\d+)(?:,(\\d+))?) \\@{2}(.*)$/;\n+\n+\t\t$from_lines = 0 unless defined $from_lines;\n+\t\t$to_lines   = 0 unless defined $to_lines;\n+\n+\t\tif ($from->{'href'}) {\n+\t\t\t$from_text = $cgi->a({-href=>\"$from->{'href'}#l$from_start\",\n+\t\t\t                     -class=>\"list\"}, $from_text);\n+\t\t}\n+\t\tif ($to->{'href'}) {\n+\t\t\t$to_text   = $cgi->a({-href=>\"$to->{'href'}#l$to_start\",\n+\t\t\t                     -class=>\"list\"}, $to_text);\n+\t\t}\n+\t\t$line = \"<span class=\\\"chunk_info\\\">@@ $from_text $to_text @@</span>\" .\n+\t\t        \"<span class=\\\"section\\\">\" . esc_html($section, -nbsp=>1) . \"</span>\";\n+\t\treturn \"<div class=\\\"diff$diff_class\\\">$line</div>\\n\";\n+\t}\n \treturn \"<div class=\\\"diff$diff_class\\\">\" . esc_html($line, -nbsp=>1) . \"</div>\\n\";\n }\n \n@@ -2372,7 +2393,7 @@ sub git_patchset_body {\n \n \t\t\tnext PATCH if ($patch_line =~ m/^diff /);\n \n-\t\t\tprint format_diff_line($patch_line);\n+\t\t\tprint format_diff_line($patch_line, \\%from, \\%to);\n \t\t}\n \n \t} continue {\n-- \n1.4.3.4\n"},{"id":"294792","messageId":"11638893462704-git-send-email-jnareb@gmail.com","threadId":"43329","inReplyTo":"1163889342877-git-send-email-jnareb@gmail.com","subject":"[PATCH 4/5] gitweb: Default to $hash_base or HEAD for $hash in \"commit\" and \"commitdiff\"","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:35:41Z","receivedAt":"2006-11-18T22:35:41Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Set $hash parameter to $hash_base || \"HEAD\" if it is not set (if it is\nnot true to be more exact). This allows [hand-edited] URLs with 'action'\n\"commit\" or \"commitdiff\" but without 'hash' parameter.\n\nIf there is 'h' (hash) parameter provided, then gitweb tries\nto use this. HEAD is used _only_ if nether hash, nor hash_base\nare provided, i.e. for URL like below\n  URL?p=project.git;a=commit\ni.e. without neither 'h' nor 'hb'.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex eadaa31..5875ba0 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3450,6 +3450,7 @@ sub git_log {\n }\n \n sub git_commit {\n+\t$hash ||= $hash_base || \"HEAD\";\n \tmy %co = parse_commit($hash);\n \tif (!%co) {\n \t\tdie_error(undef, \"Unknown commit object\");\n@@ -3727,6 +3728,7 @@ sub git_blobdiff_plain {\n \n sub git_commitdiff {\n \tmy $format = shift || 'html';\n+\t$hash ||= $hash_base || \"HEAD\";\n \tmy %co = parse_commit($hash);\n \tif (!%co) {\n \t\tdie_error(undef, \"Unknown commit object\");\n-- \n1.4.3.4\n"},{"id":"295080","messageId":"1163889347230-git-send-email-jnareb@gmail.com","threadId":"43329","inReplyTo":"1163889342877-git-send-email-jnareb@gmail.com","subject":"[PATCH 5/5] gitweb: Add an option to href() to return full URL","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:35:42Z","receivedAt":"2006-11-18T22:35:42Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"href subroutine by default generates absolute URL (generated using\nCGI::url(-absolute=>1), and saved in $my_uri) using $my_uri as base;\nadd an option to generate full URL using $my_url as base.\n\nNew feature usage: href(..., -full=>1)\n\nTo be used in web feeds (RSS, Atom, OPML) and other places which need\nfull URL rather than absolute or relative.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 5875ba0..8739501 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -459,7 +459,8 @@ exit;\n \n sub href(%) {\n \tmy %params = @_;\n-\tmy $href = $my_uri;\n+\t# default is to use -absolute url() i.e. $my_uri\n+\tmy $href = $params{-full} ? $my_url : $my_uri;\n \n \t# XXX: Warning: If you touch this, check the search form for updating,\n \t# too.\n-- \n1.4.3.4\n"},{"id":"296745","messageId":"ejo1uq$40s$1@sea.gmane.org","threadId":"43329","inReplyTo":"11638893431855-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH 1/5] gitweb: Protect against possible warning in git_commitdiff","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-18T22:38:42Z","receivedAt":"2006-11-18T22:38:42Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Possible _undefined value_ warning.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"}]}