{"thread":{"id":"5147","subject":"[PATCH 0/6] gitweb: Further refactoring","startedAt":"2006-08-06T00:06:48Z","lastAt":"2006-08-06T10:52:58Z","messageCount":12,"participants":["Jakub Narebski","Matthias Lederhofer","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"24855","messageId":"200608060206.49086.jnareb@gmail.com","threadId":"5147","inReplyTo":null,"subject":"[PATCH 0/6] gitweb: Further refactoring","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:06:48Z","receivedAt":"2006-08-06T00:06:48Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"This series of patches, on top of my merged series\n'[PATCH 7/5] Merge changes in \"split patch 1\" series'\nalthough probably would apply on top of 'next'.\n\n * [PATCH 1/5] gitweb: Refactor untabifying - converting tabs to spaces\n * [PATCH 2/6] gitweb: Simplify git_diff_print\n * [PATCH 3/6] gitweb: Remove unused parse_date invocation from\n   git_shortlog_body\n * [PATCH 4/6] gitweb: Make blob diff -p1 like commit diff\n * [PATCH 5/6] gitweb: Refactor printing shortened title in\n   git_shortlog_body and git_tags_body\n * [PATCH 6/6] gitweb: Refactor git_history_body\n\n-- \nJakub Narebski\nPoland\n"},{"id":"24857","messageId":"200608060208.31862.jnareb@gmail.com","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"[PATCH 1/6] gitweb: Refactor untabifying - converting tabs to spaces","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:08:31Z","receivedAt":"2006-08-06T00:08:31Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add untabify subroutine and use it.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   38 +++++++++++++++++++-------------------\n 1 files changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex bf1b10f..60113da 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -222,6 +222,21 @@ sub unquote {\n \treturn $str;\n }\n \n+# escape tabs (convert tabs to spaces)\n+sub untabify {\n+\tmy $line = shift;\n+\n+\twhile ((my $pos = index($line, \"\\t\")) != -1) {\n+\t\t# one out of three implementations used ($pos - 1) instead of $pos\n+\t\tif (my $count = (8 - ($pos % 8))) {\n+\t\t\tmy $spaces = ' ' x $count;\n+\t\t\t$line =~ s/\\t/$spaces/;\n+\t\t}\n+\t}\n+\n+\treturn $line;\n+}\n+\n ## ----------------------------------------------------------------------\n ## HTML aware string manipulation\n \n@@ -1255,12 +1270,7 @@ sub git_diff_print {\n \t\t\t\t# skip errors\n \t\t\t\tnext;\n \t\t\t}\n-\t\t\twhile ((my $pos = index($line, \"\\t\")) != -1) {\n-\t\t\t\tif (my $count = (8 - (($pos-1) % 8))) {\n-\t\t\t\t\tmy $spaces = ' ' x $count;\n-\t\t\t\t\t$line =~ s/\\t/$spaces/;\n-\t\t\t\t}\n-\t\t\t}\n+\t\t\t$line = untabify($line);\n \t\t\tprint \"<div class=\\\"diff$diff_class\\\">\" . esc_html($line) . \"</div>\\n\";\n \t\t}\n \t}\n@@ -1600,13 +1610,8 @@ HTML\n \t\t$age_class  = age_class($age);\n \t\t$author     = esc_html ($author);\n \t\t$author     =~ s/ /&nbsp;/g;\n-\t\t# escape tabs\n-\t\twhile ((my $pos = index($data, \"\\t\")) != -1) {\n-\t\t\tif (my $count = (8 - ($pos % 8))) {\n-\t\t\t\tmy $spaces = ' ' x $count;\n-\t\t\t\t$data =~ s/\\t/$spaces/;\n-\t\t\t}\n-\t\t}\n+\n+\t\t$data = untabify($data);\n \t\t$data = esc_html ($data);\n \n \t\tprint <<HTML;\n@@ -1728,12 +1733,7 @@ sub git_blob {\n \twhile (my $line = <$fd>) {\n \t\tchomp $line;\n \t\t$nr++;\n-\t\twhile ((my $pos = index($line, \"\\t\")) != -1) {\n-\t\t\tif (my $count = (8 - ($pos % 8))) {\n-\t\t\t\tmy $spaces = ' ' x $count;\n-\t\t\t\t$line =~ s/\\t/$spaces/;\n-\t\t\t}\n-\t\t}\n+\t\t$line = untabify($line);\n \t\tprintf \"<div class=\\\"pre\\\"><a id=\\\"l%i\\\" href=\\\"#l%i\\\" class=\\\"linenr\\\">%4i</a> %s</div>\\n\", $nr, $nr, $nr, esc_html($line);\n \t}\n \tclose $fd or print \"Reading blob failed.\\n\";\n-- \n1.4.1.1\n"},{"id":"24858","messageId":"200608060211.38604.jnareb@gmail.com","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"[PATCH 2/6] gitweb: Simplify git_diff_print","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:11:38Z","receivedAt":"2006-08-06T00:11:38Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Copy to temporaty file more directly, not using temporary variable @file.\nUse list form of open for diff invocation (we cannot use git-diff because\nfirst it doesn't support -L/--label option, and we cannot generate diff\nbetween /dev/null and blob given by it's sha1 identifier). \n\nUse \"local $/ = undef;\" for (temporary) slurp mode.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   14 +++++++-------\n 1 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 60113da..b72f12f 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1230,31 +1230,31 @@ sub git_diff_print {\n \n \t# create tmp from-file\n \tif (defined $from) {\n+\t\tlocal $/ = undef;\n \t\t$from_tmp = \"$git_temp/gitweb_\" . $$ . \"_from\";\n \t\topen my $fd2, \"> $from_tmp\";\n \t\topen my $fd, \"-|\", $GIT, \"cat-file\", \"blob\", $from;\n-\t\tmy @file = <$fd>;\n-\t\tprint $fd2 @file;\n+\t\tprint { $fd2 } <$fd>;\n \t\tclose $fd2;\n \t\tclose $fd;\n \t}\n \n \t# create tmp to-file\n \tif (defined $to) {\n+\t\tlocal $/ = undef;\n \t\t$to_tmp = \"$git_temp/gitweb_\" . $$ . \"_to\";\n \t\topen my $fd2, \"> $to_tmp\";\n \t\topen my $fd, \"-|\", $GIT, \"cat-file\", \"blob\", $to;\n-\t\tmy @file = <$fd>;\n-\t\tprint $fd2 @file;\n+\t\tprint { $fd2 } <$fd>;\n \t\tclose $fd2;\n \t\tclose $fd;\n \t}\n \n-\topen my $fd, \"-|\", \"/usr/bin/diff -u -p -L \\'$from_name\\' -L \\'$to_name\\' $from_tmp $to_tmp\";\n+\topen my $fd, \"-|\", \"/usr/bin/diff\",\n+\t\t'-u', '-p', '-L', $from_name, '-L', $to_name, $from_tmp, $to_tmp;\n \tif ($format eq \"plain\") {\n-\t\tundef $/;\n+\t\tlocal $/ = undef;\n \t\tprint <$fd>;\n-\t\t$/ = \"\\n\";\n \t} else {\n \t\twhile (my $line = <$fd>) {\n \t\t\tchomp $line;\n-- \n1.4.1.1\n"},{"id":"24856","messageId":"200608060213.04199.jnareb@gmail.com","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"[PATCH 3/6] gitweb: Remove unused parse_date invocation from git_shortlog_body","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:13:04Z","receivedAt":"2006-08-06T00:13:04Z","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---\nRemainder from refactoring\n\n gitweb/gitweb.perl |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b72f12f..cdce481 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1077,7 +1077,6 @@ sub git_shortlog_body {\n \t\t#my $ref = defined $refs ? format_mark_referencing($refs, $commit) : '';\n \t\tmy $ref = format_mark_referencing($refs, $commit);\n \t\tmy %co = parse_commit($commit);\n-\t\tmy %ad = parse_date($co{'author_epoch'});\n \t\tif ($alternate) {\n \t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n \t\t} else {\n-- \n1.4.1.1\n"},{"id":"24861","messageId":"200608060213.50613.jnareb@gmail.com","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"[PATCH 4/6] gitweb: Make blob diff -p1 like commit diff","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:13:50Z","receivedAt":"2006-08-06T00:13:50Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add 'a/' and 'b/' as prefix for blobdiff, blobdiff_plain, like it is\nin commitdiff, commitdiff_plain.  Ensure that label for /dev/null is\nactually /dev/null.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nFor consistency.\n\n gitweb/gitweb.perl |   10 ++++++++--\n 1 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex cdce481..f402c8f 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1236,6 +1236,8 @@ sub git_diff_print {\n \t\tprint { $fd2 } <$fd>;\n \t\tclose $fd2;\n \t\tclose $fd;\n+\t} else {\n+\t\t$from_name = \"/dev/null\";\n \t}\n \n \t# create tmp to-file\n@@ -1247,6 +1249,8 @@ sub git_diff_print {\n \t\tprint { $fd2 } <$fd>;\n \t\tclose $fd2;\n \t\tclose $fd;\n+\t} else {\n+\t\t$to_name = \"/dev/null\";\n \t}\n \n \topen my $fd, \"-|\", \"/usr/bin/diff\",\n@@ -2105,7 +2109,8 @@ sub git_blobdiff {\n \t      \" -> blob:\" .\n \t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name\")}, $hash) .\n \t      \"</div>\\n\";\n-\tgit_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);\n+\tgit_diff_print($hash_parent, 'a/' . ($file_name || $hash_parent),\n+\t               $hash,        'b/' . ($file_name || $hash));\n \tprint \"</div>\";\n \tgit_footer_html();\n }\n@@ -2113,7 +2118,8 @@ sub git_blobdiff {\n sub git_blobdiff_plain {\n \tmkdir($git_temp, 0700);\n \tprint $cgi->header(-type => \"text/plain\", -charset => 'utf-8');\n-\tgit_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash, \"plain\");\n+\tgit_diff_print($hash_parent, 'a/' . ($file_name || $hash_parent),\n+\t               $hash,        'b/' . ($file_name || $hash), \"plain\");\n }\n \n sub git_commitdiff {\n-- \n1.4.1.1\n"},{"id":"24859","messageId":"200608060214.33866.jnareb@gmail.com","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"[PATCH 5/6] gitweb: Refactor printing shortened title in git_shortlog_body and git_tags_body","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:14:33Z","receivedAt":"2006-08-06T00:14:33Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Uses ugly workaround with $bold argument because style is not set via\nCSS, but via presentation element <b>...</b>.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nProbably needs better name, too\n\n gitweb/gitweb.perl |   39 +++++++++++++++++++++++----------------\n 1 files changed, 23 insertions(+), 16 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f402c8f..7ea52b1 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1062,6 +1062,27 @@ sub git_print_page_path {\n }\n \n ## ......................................................................\n+## functions printing or outputting HTML: inline elements\n+\n+# print, perhaps shortened and with markers, title line\n+sub print_title_html {\n+\t# $bold argument is workaround until style will be set via CSS\n+\tmy ($long, $short, $query, $bold, $extra) = @_;\n+\t$extra = '' unless defined($extra);\n+\n+\tif (length($short) < length($long)) {\n+\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param($query),\n+\t\t               -class => \"list\", -title => $long},\n+\t\t      ($bold ? \"<b>\" : \"\") . esc_html($short) . $extra . ($bold ? \"</b>\" : \"\"));\n+\t} else {\n+\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param($query),\n+\t\t               -class => \"list\"},\n+\t\t      ($bold ? \"<b>\" : \"\") . esc_html($long)  . $extra . ($bold ? \"</b>\" : \"\"));\n+\t}\n+}\n+\n+\n+## ......................................................................\n ## functions printing large fragments of HTML\n \n sub git_shortlog_body {\n@@ -1087,15 +1108,7 @@ sub git_shortlog_body {\n \t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n \t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 10)) . \"</i></td>\\n\" .\n \t\t      \"<td>\";\n-\t\tif (length($co{'title_short'}) < length($co{'title'})) {\n-\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\"),\n-\t\t\t               -class => \"list\", -title => \"$co{'title'}\"},\n-\t\t\t      \"<b>\" . esc_html($co{'title_short'}) . \"$ref</b>\");\n-\t\t} else {\n-\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\"),\n-\t\t\t               -class => \"list\"},\n-\t\t\t      \"<b>\" . esc_html($co{'title'}) . \"$ref</b>\");\n-\t\t}\n+\t\tprint_title_html($co{'title'}, $co{'title_short'}, \"p=$project;a=commit;h=$commit\", 1, $ref);\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\")}, \"commit\") . \" | \" .\n@@ -1141,13 +1154,7 @@ sub git_tags_body {\n \t\t      \"</td>\\n\" .\n \t\t      \"<td>\";\n \t\tif (defined $comment) {\n-\t\t\tif (length($comment_short) < length($comment)) {\n-\t\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tag;h=$tag{'id'}\"),\n-\t\t\t\t               -class => \"list\", -title => $comment}, $comment_short);\n-\t\t\t} else {\n-\t\t\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tag;h=$tag{'id'}\"),\n-\t\t\t\t               -class => \"list\"}, $comment);\n-\t\t\t}\n+\t\t\tprint_title_html($comment, $comment_short, \"p=$project;a=tag;h=$tag{'id'}\");\n \t\t}\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"selflink\\\">\";\n-- \n1.4.1.1\n"},{"id":"24860","messageId":"200608060217.07512.jnareb@gmail.com","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"[PATCH 6/6] gitweb: Refactor git_history_body","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T00:17:07Z","receivedAt":"2006-08-06T00:17:07Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Separates main part of git_history into git_history_body subroutine,\nand make output more similar to git_shortlog.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nWe couldn't just modify git_shortlog, because git_shortlog reads full\n(--max-count limited) output of rev-list to array, which is needed \nfor dividing into pages and pagination navigation bar, while git_history\nreads rev-list output line by line.\n\n gitweb/gitweb.perl |   93 ++++++++++++++++++++++++++++++++--------------------\n 1 files changed, 57 insertions(+), 36 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 7ea52b1..2a39145 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1124,6 +1124,62 @@ sub git_shortlog_body {\n \tprint \"</table>\\n\";\n }\n \n+sub git_history_body {\n+\t# Warning: assumes constant type (blob or tree) during history\n+\tmy ($fd, $refs, $hash_base, $ftype, $extra) = @_;\n+\n+\tprint \"<table class=\\\"history\\\" cellspacing=\\\"0\\\">\\n\";\n+\tmy $alternate = 0;\n+\twhile (my $line = <$fd>) {\n+\t\tif ($line !~ m/^([0-9a-fA-F]{40})/) {\n+\t\t\tnext;\n+\t\t}\n+\n+\t\tmy $commit = $1;\n+\t\tmy %co = parse_commit($commit);\n+\t\tif (!%co) {\n+\t\t\tnext;\n+\t\t}\n+\n+\t\tmy $ref = format_mark_referencing($refs, $commit);\n+\n+\t\tif ($alternate) {\n+\t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n+\t\t} else {\n+\t\t\tprint \"<tr class=\\\"light\\\">\\n\";\n+\t\t}\n+\t\t$alternate ^= 1;\n+\t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n+\t\t      # shortlog uses      chop_str($co{'author_name'}, 10)\n+\t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 15, 3)) . \"</i></td>\\n\" .\n+\t\t      \"<td>\";\n+\t\t# originally git_history used chop_str($co{'title'}, 50)\n+\t\tprint_title_html($co{'title'}, $co{'title_short'}, \"p=$project;a=commit;h=$commit\", 1, $ref);\n+\t\tprint \"</td>\\n\" .\n+\t\t      \"<td class=\\\"link\\\">\" .\n+\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\")}, \"commit\") . \" | \" .\n+\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff;h=$commit\")}, \"commitdiff\") . \" | \" .\n+\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$ftype;hb=$commit;f=$file_name\")}, $ftype);\n+\n+\t\tmy $blob_current = git_get_hash_by_path($hash_base, $file_name);\n+\t\tmy $blob_parent  = git_get_hash_by_path($commit, $file_name);\n+\t\tif (defined $blob_current && defined $blob_parent &&\n+\t\t\t\t$blob_current ne $blob_parent) {\n+\t\t\tprint \" | \" .\n+\t\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blobdiff;h=$blob_current;hp=$blob_parent;hb=$commit;f=$file_name\")},\n+\t\t\t\t\"diff to current\");\n+\t\t}\n+\t\tprint \"</td>\\n\" .\n+\t\t      \"</tr>\\n\";\n+\t}\n+\tif (defined $extra) {\n+\t\tprint \"<tr>\\n\" .\n+\t\t      \"<td colspan=\\\"4\\\">$extra</td>\\n\" .\n+\t\t      \"</tr>\\n\";\n+\t}\n+\tprint \"</table>\\n\";\n+}\n+\n sub git_tags_body {\n \t# uses global variable $project\n \tmy ($taglist, $from, $to, $extra) = @_;\n@@ -2295,42 +2351,7 @@ sub git_history {\n \n \topen my $fd, \"-|\",\n \t\t$GIT, \"rev-list\", \"--full-history\", $hash_base, \"--\", $file_name;\n-\tprint \"<table cellspacing=\\\"0\\\">\\n\";\n-\tmy $alternate = 0;\n-\twhile (my $line = <$fd>) {\n-\t\tif ($line =~ m/^([0-9a-fA-F]{40})/){\n-\t\t\tmy $commit = $1;\n-\t\t\tmy %co = parse_commit($commit);\n-\t\t\tif (!%co) {\n-\t\t\t\tnext;\n-\t\t\t}\n-\t\t\tmy $ref = format_mark_referencing($refs, $commit);\n-\t\t\tif ($alternate) {\n-\t\t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n-\t\t\t} else {\n-\t\t\t\tprint \"<tr class=\\\"light\\\">\\n\";\n-\t\t\t}\n-\t\t\t$alternate ^= 1;\n-\t\t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n-\t\t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 15, 3)) . \"</i></td>\\n\" .\n-\t\t\t      \"<td>\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\"), -class => \"list\"}, \"<b>\" .\n-\t\t\t      esc_html(chop_str($co{'title'}, 50)) . \"$ref</b>\") . \"</td>\\n\" .\n-\t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$commit\")}, \"commit\") .\n-\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff;h=$commit\")}, \"commitdiff\") .\n-\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=$ftype;hb=$commit;f=$file_name\")}, $ftype);\n-\t\t\tmy $blob = git_get_hash_by_path($hash_base, $file_name);\n-\t\t\tmy $blob_parent = git_get_hash_by_path($commit, $file_name);\n-\t\t\tif (defined $blob && defined $blob_parent && $blob ne $blob_parent) {\n-\t\t\t\tprint \" | \" .\n-\t\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name\")},\n-\t\t\t\t\"diff to current\");\n-\t\t\t}\n-\t\t\tprint \"</td>\\n\" .\n-\t\t\t      \"</tr>\\n\";\n-\t\t}\n-\t}\n-\tprint \"</table>\\n\";\n+\tgit_history_body($fd, $refs, $hash_base, $ftype);\n \tclose $fd;\n \tgit_footer_html();\n }\n-- \n1.4.1.1\n"},{"id":"24879","messageId":"20060806083116.GA25594@moooo.ath.cx","threadId":"5147","inReplyTo":"200608060208.31862.jnareb@gmail.com","subject":"Re: [PATCH 1/6] gitweb: Refactor untabifying - converting tabs to spaces","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-06T08:31:16Z","receivedAt":"2006-08-06T08:31:16Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> +\t\t# one out of three implementations used ($pos - 1) instead of $pos\nPerhaps this should be in the commit message instead of the source?\nI think no one will later understand this comment without the commit.\n"},{"id":"24881","messageId":"7v8xm2b4g3.fsf@assigned-by-dhcp.cox.net","threadId":"5147","inReplyTo":"200608060211.38604.jnareb@gmail.com","subject":"Re: [PATCH 2/6] gitweb: Simplify git_diff_print","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-06T09:26:20Z","receivedAt":"2006-08-06T09:26:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Copy to temporaty file more directly, not using temporary variable @file.\n> Use list form of open for diff invocation (we cannot use git-diff because\n> first it doesn't support -L/--label option, and we cannot generate diff\n> between /dev/null and blob given by it's sha1 identifier). \n>\n> Use \"local $/ = undef;\" for (temporary) slurp mode.\n>\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n\nI think this part of the gitweb code predates the git-diff\nsupport by the core level.  If I recall correctly, back then we\ndid not even have \"git-diff-{tree,files,index}\" when this part\nwas written.\n\nI think you could use \"git-diff $from $to\" instead of using\ntemporary files and running /usr/bin/diff on it with today's\ngit.  Which is a big win from both security and ease of\nadministration point of view.  Not having to write anything into\ntemporary file from gitweb.cgi means you do not have to worry\nabout stray gitweb process leaving temporary files dangling\nbehind, for example.\n\nYou obviously would need to emulate the -L$from_name -L$to_name\npart by hand in the loop that reads from the diff output.\n\nOne worrysome pathological case is what happens if files being\ntracked happen to have names that consist of 40-byte hexdigits.\nI think \"git-diff $from $to --\" should do the right thing for\ngitweb use ($from and $to should not mistaken taken as pathnames\nwith the explicit -- disambiguator) and \"git-diff -- $from $to\"\nalso should do the right thing to take $from and $to as pathnames\neven if there are revisions with the same object names, but\nsomebody may want to verify that (and send patches to fix if it\nis not the case).\n"},{"id":"24882","messageId":"7vmzai89o1.fsf@assigned-by-dhcp.cox.net","threadId":"5147","inReplyTo":"200608060206.49086.jnareb@gmail.com","subject":"Re: [PATCH 0/6] gitweb: Further refactoring","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-06T10:01:50Z","receivedAt":"2006-08-06T10:01:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The earlier 9-series looked fine, so I intend to apply them all\nto \"next\".  However, they were all tab damaged and it was very\npainful to fix up the patch.\n\nThis series, PATCH 1/5 (6?) looks fine (it is a bugfix for\ngit_diff_print), but among others, one of them had a seriously\nfishy preimage (e.g. as you can see in \"next\", I haven't\naccepted the function rename patch but 3/6 talks about\nformat_mark_referencing), and at that point my patience ran out.\n\nPlease check what I pushed out on \"next\"/\"pu\" tonight, and\nconsider patches missing from there dropped on the floor for now\n(which does not mean they are rejected, except for the one that\ntouches diff_print and still uses /usr/bin/diff, which I\ncommented on).  It probably is a good idea to make sure further\npatches resent are based on (or at least apply cleanly to) the\ncommit f16db173a4680aebc2f14c103a1e125c3f4d4531.\n\nPlease note that I am primarily concentrating on polishing what\nis in \"master\" to finish 1.4.2 for now, so I might have missed\nbreakage in these gitweb patches that I queued for \"next\".\n\nComments, tests and fixups are all very welcomed.\n"},{"id":"24883","messageId":"eb4fs7$i7i$1@sea.gmane.org","threadId":"5147","inReplyTo":"7v8xm2b4g3.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/6] gitweb: Simplify git_diff_print","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T10:22:48Z","receivedAt":"2006-08-06T10:22:48Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> Copy to temporaty file more directly, not using temporary variable @file.\n>> Use list form of open for diff invocation (we cannot use git-diff because\n>> first it doesn't support -L/--label option, and we cannot generate diff\n>> between /dev/null and blob given by it's sha1 identifier). \n>>\n>> Use \"local $/ = undef;\" for (temporary) slurp mode.\n>>\n>> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> \n> I think this part of the gitweb code predates the git-diff\n> support by the core level.  If I recall correctly, back then we\n> did not even have \"git-diff-{tree,files,index}\" when this part\n> was written.\n> \n> I think you could use \"git-diff $from $to\" instead of using\n> temporary files and running /usr/bin/diff on it with today's\n> git.  Which is a big win from both security and ease of\n> administration point of view.  Not having to write anything into\n> temporary file from gitweb.cgi means you do not have to worry\n> about stray gitweb process leaving temporary files dangling\n> behind, for example.\n\nIf I remember gitweb code correctly, diff to /dev/null is called\n_only_ in commitdiff, where we can use git-diff -p to generate patch\ndirectly, instead of generating difftree and calling diff on entries.\n\nStill it would be nice if git-diff could diff between blob and arbitrary\nfile on filesystem (including /dev/null), and acquired -L/--label option.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24885","messageId":"eb4hkp$m0o$1@sea.gmane.org","threadId":"5147","inReplyTo":"7vmzai89o1.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 0/6] gitweb: Further refactoring","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T10:52:58Z","receivedAt":"2006-08-06T10:52:58Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> The earlier 9-series looked fine, so I intend to apply them all\n> to \"next\".  However, they were all tab damaged and it was very\n> painful to fix up the patch.\n\nI'm sorry for that. As far as I checked, KNode (news reader which I used for\nsending 9-(micro)series) preserves tabs when attaching file inline. I guess\nthat GMane news-to-mail gateway might munge whitespace. I won't use KNode\nto send patches, then.\n\nBy the way, can anyone tell me how to setup git-send-email to send email via\nGMail (authenticated SMTP, via STARTTLS/SSL, on ports 25 or 465 or 587)?\n\n> This series, PATCH 1/5 (6?) looks fine (it is a bugfix for\n> git_diff_print), but among others, one of them had a seriously\n> fishy preimage (e.g. as you can see in \"next\", I haven't\n> accepted the function rename patch but 3/6 talks about\n> format_mark_referencing), and at that point my patience ran out.\n\nI _have_ notified that this 6-series is on top of previous series,\nnamely '[PATCH 7/5] Merge changes in \"split patch 1\" series' patch.\n\nBut I try to redo not accepted changes on top of next, and put\n\"gitweb: Great subroutines renaming\" on top of series. (BTW. this \nis simple search'n'replace on subroutine names... well, perhaps after\n1.4.2...).\n\n[...]\n> Please note that I am primarily concentrating on polishing what\n> is in \"master\" to finish 1.4.2 for now, so I might have missed\n> breakage in these gitweb patches that I queued for \"next\".\n\nI'm trying to check my gitweb patches, by checking the output of all\npossible actions, althought I think it doesn't encompass all the cases...\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}