{"thread":{"id":"5986","subject":"[PATCH 0/4] gitweb: Improving tree view (plus some cleanups)","startedAt":"2006-10-21T15:50:48Z","lastAt":"2006-10-22T23:36:44Z","messageCount":11,"participants":["Jakub Narebski","Junio C Hamano","Linus Torvalds","Luben Tuikov"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"29505","messageId":"200610211750.49188.jnareb@gmail.com","threadId":"5986","inReplyTo":null,"subject":"[PATCH 0/4] gitweb: Improving tree view (plus some cleanups)","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-21T15:50:48Z","receivedAt":"2006-10-21T15:50:48Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"This series of patches is road to patch introducing '..'\n(up directory) link in \"tree\" view in gitweb; patches 1-3\ncorrects errors or inconistencies noticed in code generating\n\"tree\" view.\n\nShortlog:\n [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)\n [PATCH 2/4] gitweb: Do not esc_html $basedir argument to git_print_tree_entry\n [PATCH 3/4] gitweb: Improve git_print_page_path\n [PATCH 4/4] gitweb: Add '..' (up directory) to tree view if applicable.\n\nDiffstat:\n---\n gitweb/gitweb.perl |  109 ++++++++++++++++++++++++++++++++--------------------\n 1 files changed, 68 insertions(+), 41 deletions(-)\n\n-- \nJakub Narebski\nShadeHawk on #git\nPoland\n"},{"id":"29507","messageId":"200610211752.19891.jnareb@gmail.com","threadId":"5986","inReplyTo":"200610211750.49188.jnareb@gmail.com","subject":"[PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-21T15:52:19Z","receivedAt":"2006-10-21T15:52:19Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Code should be aligned the same way, regardless of tab size.\nUse tabs for indent, but spaces for align.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n gitweb/gitweb.perl |   60 ++++++++++++++++++++++++++--------------------------\n 1 files changed, 30 insertions(+), 30 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 035e85e..c457884 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1722,13 +1722,13 @@ sub git_print_tree_entry {\n \tif ($t->{'type'} eq \"blob\") {\n \t\tprint \"<td class=\\\"list\\\">\" .\n \t\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$t->{'hash'},\n-\t\t\t\t\t       file_name=>\"$basedir$t->{'name'}\", %base_key),\n-\t\t\t\t -class => \"list\"}, esc_html($t->{'name'})) . \"</td>\\n\";\n+\t\t\t                       file_name=>\"$basedir$t->{'name'}\", %base_key),\n+\t\t\t        -class => \"list\"}, esc_html($t->{'name'})) . \"</td>\\n\";\n \t\tprint \"<td class=\\\"link\\\">\";\n \t\tif ($have_blame) {\n \t\t\tprint $cgi->a({-href => href(action=>\"blame\", hash=>$t->{'hash'},\n-\t\t\t\t\t\t     file_name=>\"$basedir$t->{'name'}\", %base_key)},\n-\t\t\t\t      \"blame\");\n+\t\t\t\t                           file_name=>\"$basedir$t->{'name'}\", %base_key)},\n+\t\t\t\t            \"blame\");\n \t\t}\n \t\tif (defined $hash_base) {\n \t\t\tif ($have_blame) {\n@@ -1740,8 +1740,8 @@ sub git_print_tree_entry {\n \t\t}\n \t\tprint \" | \" .\n \t\t\t$cgi->a({-href => href(action=>\"blob_plain\", hash_base=>$hash_base,\n-\t\t\t\t\t       file_name=>\"$basedir$t->{'name'}\")},\n-\t\t\t\t\"raw\");\n+\t\t\t                       file_name=>\"$basedir$t->{'name'}\")},\n+\t\t\t        \"raw\");\n \t\tprint \"</td>\\n\";\n \n \t} elsif ($t->{'type'} eq \"tree\") {\n@@ -1809,7 +1809,7 @@ sub git_difftree_body {\n \t\t\tprint \"<td>\";\n \t\t\tprint $cgi->a({-href => href(action=>\"blob\", hash=>$diff{'to_id'},\n \t\t\t                             hash_base=>$hash, file_name=>$diff{'file'}),\n-\t\t\t\t       -class => \"list\"}, esc_html($diff{'file'}));\n+\t\t\t              -class => \"list\"}, esc_html($diff{'file'}));\n \t\t\tprint \"</td>\\n\";\n \t\t\tprint \"<td>$mode_chng</td>\\n\";\n \t\t\tprint \"<td class=\\\"link\\\">\";\n@@ -1836,11 +1836,11 @@ sub git_difftree_body {\n \t\t\t\tprint \" | \";\n \t\t\t}\n \t\t\tprint $cgi->a({-href => href(action=>\"blame\", hash_base=>$parent,\n-\t\t\t\t\t\t     file_name=>$diff{'file'})},\n-\t\t\t\t      \"blame\") . \" | \";\n+\t\t\t                             file_name=>$diff{'file'})},\n+\t\t\t              \"blame\") . \" | \";\n \t\t\tprint $cgi->a({-href => href(action=>\"history\", hash_base=>$parent,\n-\t\t\t\t\t\t     file_name=>$diff{'file'})},\n-\t\t\t\t      \"history\");\n+\t\t\t                             file_name=>$diff{'file'})},\n+\t\t\t              \"history\");\n \t\t\tprint \"</td>\\n\";\n \n \t\t} elsif ($diff{'status'} eq \"M\" || $diff{'status'} eq \"T\") { # modified, or type changed\n@@ -1861,8 +1861,8 @@ sub git_difftree_body {\n \t\t\t}\n \t\t\tprint \"<td>\";\n \t\t\tprint $cgi->a({-href => href(action=>\"blob\", hash=>$diff{'to_id'},\n-\t\t\t\t\t\t     hash_base=>$hash, file_name=>$diff{'file'}),\n-\t\t\t\t       -class => \"list\"}, esc_html($diff{'file'}));\n+\t\t\t                             hash_base=>$hash, file_name=>$diff{'file'}),\n+\t\t\t              -class => \"list\"}, esc_html($diff{'file'}));\n \t\t\tprint \"</td>\\n\";\n \t\t\tprint \"<td>$mode_chnge</td>\\n\";\n \t\t\tprint \"<td class=\\\"link\\\">\";\n@@ -1873,19 +1873,19 @@ sub git_difftree_body {\n \t\t\t\t\tprint $cgi->a({-href => \"#patch$patchno\"}, \"patch\");\n \t\t\t\t} else {\n \t\t\t\t\tprint $cgi->a({-href => href(action=>\"blobdiff\",\n-\t\t\t\t\t\t\t\t     hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},\n-\t\t\t\t\t\t\t\t     hash_base=>$hash, hash_parent_base=>$parent,\n-\t\t\t\t\t\t\t\t     file_name=>$diff{'file'})},\n-\t\t\t\t\t\t      \"diff\");\n+\t\t\t\t\t                             hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},\n+\t\t\t\t\t                             hash_base=>$hash, hash_parent_base=>$parent,\n+\t\t\t\t\t                             file_name=>$diff{'file'})},\n+\t\t\t\t\t              \"diff\");\n \t\t\t\t}\n \t\t\t\tprint \" | \";\n \t\t\t}\n \t\t\tprint $cgi->a({-href => href(action=>\"blame\", hash_base=>$hash,\n-\t\t\t\t\t\t     file_name=>$diff{'file'})},\n-\t\t\t\t      \"blame\") . \" | \";\n+\t\t\t                             file_name=>$diff{'file'})},\n+\t\t\t              \"blame\") . \" | \";\n \t\t\tprint $cgi->a({-href => href(action=>\"history\", hash_base=>$hash,\n-\t\t\t\t\t\t     file_name=>$diff{'file'})},\n-\t\t\t\t      \"history\");\n+\t\t\t                             file_name=>$diff{'file'})},\n+\t\t\t              \"history\");\n \t\t\tprint \"</td>\\n\";\n \n \t\t} elsif ($diff{'status'} eq \"R\" || $diff{'status'} eq \"C\") { # renamed or copied\n@@ -1913,19 +1913,19 @@ sub git_difftree_body {\n \t\t\t\t\tprint $cgi->a({-href => \"#patch$patchno\"}, \"patch\");\n \t\t\t\t} else {\n \t\t\t\t\tprint $cgi->a({-href => href(action=>\"blobdiff\",\n-\t\t\t\t\t\t\t\t     hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},\n-\t\t\t\t\t\t\t\t     hash_base=>$hash, hash_parent_base=>$parent,\n-\t\t\t\t\t\t\t\t     file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},\n-\t\t\t\t\t\t      \"diff\");\n+\t\t\t\t\t                             hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},\n+\t\t\t\t\t                             hash_base=>$hash, hash_parent_base=>$parent,\n+\t\t\t\t\t                             file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},\n+\t\t\t\t\t              \"diff\");\n \t\t\t\t}\n \t\t\t\tprint \" | \";\n \t\t\t}\n \t\t\tprint $cgi->a({-href => href(action=>\"blame\", hash_base=>$parent,\n-\t\t\t\t\t\t     file_name=>$diff{'from_file'})},\n-\t\t\t\t      \"blame\") . \" | \";\n+\t\t\t                             file_name=>$diff{'from_file'})},\n+\t\t\t              \"blame\") . \" | \";\n \t\t\tprint $cgi->a({-href => href(action=>\"history\", hash_base=>$parent,\n-\t\t\t\t\t\t     file_name=>$diff{'from_file'})},\n-\t\t\t\t      \"history\");\n+\t\t\t                            file_name=>$diff{'from_file'})},\n+\t\t\t              \"history\");\n \t\t\tprint \"</td>\\n\";\n \n \t\t} # we should not encounter Unmerged (U) or Unknown (X) status\n@@ -2851,7 +2851,7 @@ sub git_tree {\n \t\t\t# FIXME: Should be available when we have no hash base as well.\n \t\t\tpush @views_nav,\n \t\t\t\t$cgi->a({-href => href(action=>\"snapshot\", hash=>$hash)},\n-\t\t\t\t\t\"snapshot\");\n+\t\t\t\t        \"snapshot\");\n \t\t}\n \t\tgit_print_page_nav('tree','', $hash_base, undef, undef, join(' | ', @views_nav));\n \t\tgit_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);\n-- \n1.4.2.1\n"},{"id":"29508","messageId":"200610211753.09343.jnareb@gmail.com","threadId":"5986","inReplyTo":"200610211750.49188.jnareb@gmail.com","subject":"[PATCH 2/4] gitweb: Do not esc_html $basedir argument to git_print_tree_entry","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-21T15:53:09Z","receivedAt":"2006-10-21T15:53:09Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"In git_tree, rename $base variable (which is passed as $basedir\nargument to git_print_tree_entry) to $basedir. Do not esc_html\n$basedir, as it is part of file_name ('f') argument in link and not\nprinted. Add '/' at the end only if $basedir is not empty (it is empty\nfor top directory) and doesn't end in '/' already.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nBUGFIX patch.\n\n gitweb/gitweb.perl |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex c457884..209b318 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2834,7 +2834,7 @@ sub git_tree {\n \tmy $refs = git_get_references();\n \tmy $ref = format_ref_marker($refs, $hash_base);\n \tgit_header_html();\n-\tmy $base = \"\";\n+\tmy $basedir = '';\n \tmy ($have_blame) = gitweb_check_feature('blame');\n \tif (defined $hash_base && (my %co = parse_commit($hash_base))) {\n \t\tmy @views_nav = ();\n@@ -2862,7 +2862,10 @@ sub git_tree {\n \t\tprint \"<div class=\\\"title\\\">$hash</div>\\n\";\n \t}\n \tif (defined $file_name) {\n-\t\t$base = esc_html(\"$file_name/\");\n+\t\t$basedir = $file_name;\n+\t\tif ($basedir ne '' && substr($basedir, -1) ne '/') {\n+\t\t\t$basedir .= '/';\n+\t\t}\n \t}\n \tgit_print_page_path($file_name, 'tree', $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n@@ -2878,7 +2881,7 @@ sub git_tree {\n \t\t}\n \t\t$alternate ^= 1;\n \n-\t\tgit_print_tree_entry(\\%t, $base, $hash_base, $have_blame);\n+\t\tgit_print_tree_entry(\\%t, $basedir, $hash_base, $have_blame);\n \n \t\tprint \"</tr>\\n\";\n \t}\n-- \n1.4.2.1\n"},{"id":"29506","messageId":"200610211753.56029.jnareb@gmail.com","threadId":"5986","inReplyTo":"200610211750.49188.jnareb@gmail.com","subject":"[PATCH 3/4] gitweb: Improve git_print_page_path","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-21T15:53:55Z","receivedAt":"2006-10-21T15:53:55Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Add link to \"tree root\" (root directory) also for not defined name,\nfor example for \"tree\" action without defined \"file_name\" which means\n\"tree root\".\n\nAdd \" / \" at the end of path when $type eq \"tree\".\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nConsistency (and code simplification).\n\n gitweb/gitweb.perl |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 209b318..126cf3c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1615,17 +1615,16 @@ sub git_print_page_path {\n \tmy $type = shift;\n \tmy $hb = shift;\n \n-\tif (!defined $name) {\n-\t\tprint \"<div class=\\\"page_path\\\">/</div>\\n\";\n-\t} else {\n+\n+\tprint \"<div class=\\\"page_path\\\">\";\n+\tprint $cgi->a({-href => href(action=>\"tree\", hash_base=>$hb),\n+\t              -title => 'tree root'}, \"[$project]\");\n+\tprint \" / \";\n+\tif (defined $name) {\n \t\tmy @dirname = split '/', $name;\n \t\tmy $basename = pop @dirname;\n \t\tmy $fullname = '';\n \n-\t\tprint \"<div class=\\\"page_path\\\">\";\n-\t\tprint $cgi->a({-href => href(action=>\"tree\", hash_base=>$hb),\n-\t\t\t      -title => 'tree root'}, \"[$project]\");\n-\t\tprint \" / \";\n \t\tforeach my $dir (@dirname) {\n \t\t\t$fullname .= ($fullname ? '/' : '') . $dir;\n \t\t\tprint $cgi->a({-href => href(action=>\"tree\", file_name=>$fullname,\n@@ -1641,11 +1640,12 @@ sub git_print_page_path {\n \t\t\tprint $cgi->a({-href => href(action=>\"tree\", file_name=>$file_name,\n \t\t\t                             hash_base=>$hb),\n \t\t\t              -title => $name}, esc_html($basename));\n+\t\t\tprint \" / \";\n \t\t} else {\n \t\t\tprint esc_html($basename);\n \t\t}\n-\t\tprint \"<br/></div>\\n\";\n \t}\n+\tprint \"<br/></div>\\n\";\n }\n \n # sub git_print_log (\\@;%) {\n-- \n1.4.2.1\n"},{"id":"29509","messageId":"200610211754.44981.jnareb@gmail.com","threadId":"5986","inReplyTo":"200610211750.49188.jnareb@gmail.com","subject":"[PATCH 4/4] gitweb: Add '..' (up directory) to tree view if applicable","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-21T15:54:44Z","receivedAt":"2006-10-21T15:54:44Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Adds '..' (up directory) link at the top of \"tree\" view listing,\nif both $hash_base and $file_name are provided, and $file_name\nis not empty string.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis was meant to send as single patch...\n\n gitweb/gitweb.perl |   24 ++++++++++++++++++++++++\n 1 files changed, 24 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 126cf3c..c9e57f0 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2871,6 +2871,30 @@ sub git_tree {\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n \tprint \"<table cellspacing=\\\"0\\\">\\n\";\n \tmy $alternate = 1;\n+\t# '..' (top directory) link if possible\n+\tif (defined $hash_base &&\n+\t    defined $file_name && $file_name =~ m![^/]+$!) {\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+\n+\t\tmy $up = $file_name;\n+\t\t$up =~ s!/?[^/]+$!!;\n+\t\tundef $up unless $up;\n+\t\t# based on git_print_tree_entry\n+\t\tprint '<td class=\"mode\">' . mode_str('040000') . \"</td>\\n\";\n+\t\tprint '<td class=\"list\">';\n+\t\tprint $cgi->a({-href => href(action=>\"tree\", hash_base=>$hash_base,\n+\t\t                             file_name=>$up)},\n+\t\t              \"..\");\n+\t\tprint \"</td>\\n\";\n+\t\tprint \"<td class=\\\"link\\\"></td>\\n\";\n+\n+\t\tprint \"</tr>\\n\";\n+\t}\n \tforeach my $line (@entries) {\n \t\tmy %t = parse_ls_tree_line($line, -z => 1);\n \n-- \n1.4.2.1\n"},{"id":"29667","messageId":"7v3b9g5cde.fsf@assigned-by-dhcp.cox.net","threadId":"5986","inReplyTo":"200610211752.19891.jnareb@gmail.com","subject":"Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-22T20:22:53Z","receivedAt":"2006-10-22T20:22:53Z","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> Code should be aligned the same way, regardless of tab size.\n> Use tabs for indent, but spaces for align.\n\nI do not necessarily agree with that policy; the result of\napplying this patch is still inconsistent in some places, and I\nthink that is primarily because the policy itself is flawed.\n\nFor example, a part of sub format_paging_nav looks like this:\n\n        sub format_paging_nav {\n        >>>>>>>>my ($action, $hash, $head, $page, $nrevs) = @_;\n        ...\n        >>>>>>>>if ($page > 0) {\n        >>>>>>>>>>>>>>>>$paging_nav .= \" &sdot; \" .\n        >>>>>>>>>>>>>>>>>>>>>>>>$cgi->a({-href => href(action=>$a\n        >>>>>>>>>>>>>>>>>>>>>>>>         -accesskey => \"p\", -titl\n        >>>>>>>>} else {\n        ...\n\nIf your policy is to indent continuation lines (which is why you\nhave a TAB before \"$cgi->a\"), not having a TAB before the\ncontinued parameter list for the $cgi->a() call look inconsistent.\n\nIf on the other hand your policy is to align parameters to an\noperator that are spread over multiple lines, \" &sdot; \" and\n\"$cgi-a(...\" are left and right parameters to the string\nconcatenation operator \".\" in between them, so \"$cgi->a\" should\nbe pushed back with a run of SP starting at the column that\nbegins $paging_nav and aligned with the DQ at the beginning of\nthe \" &sdot; \" string.\n\nBy the way, is there a handy way to view something like the\nabove with \"cat\" (like \"cat -e\" is an easy way to find trailing\nwhitespace problems)?  I usually end up running this but I feel\nthat there ought to be a canned command.\n\n#!/usr/bin/perl\n\nmy $monochrome = 0;\nmy $tab = 8;\nmy $tab_color = \"\\033[44m\";\nmy $reset_color = \"\\033[0m\";\nmy $tab_padchar = ' ';\n\nif ($monochrome) {\n\t$tab_color = $reset_color = '';\n\t$tab_padchar = '>';\n}\n\nwhile (<>) {\n\tchomp;\n\tmy (@frag) = split(/\\t/, $_);\n\tmy $pos = 0;\n\tfor (my $i = 0; $i < @frag; $i++) {\n\t\tif ($i) {\n\t\t\tmy $len = 8 - $pos % 8;\n\t\t\tprint $tab_color;\n\t\t\tprint $tab_padchar x $len;\n\t\t\tprint $reset_color;\n\t\t\t$pos += $len;\n\t\t}\n\t\tprint $frag[$i];\n\t\t$pos += length($frag[$i]);\n\n\t}\n\tprint \"\\n\";\n}\n"},{"id":"29668","messageId":"200610222236.45414.jnareb@gmail.com","threadId":"5986","inReplyTo":"7v3b9g5cde.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-22T20:36:45Z","receivedAt":"2006-10-22T20:36:45Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> Code should be aligned the same way, regardless of tab size.\n>> Use tabs for indent, but spaces for align.\n> \n> I do not necessarily agree with that policy; the result of\n> applying this patch is still inconsistent in some places, and I\n> think that is primarily because the policy itself is flawed.\n\nTo be true I do those \"whitespace cleanup\" patches when I notice\nthat something is mis-aligned for _my_ tab width (2 spaces).\nI use Emacs with show-whitespace-mode to not introduce errors\nwhich would be aligned for 2 columsn wide tabs but be misaligned\nfor more common 5 or 8 characters wide tabs.\n \n> For example, a part of sub format_paging_nav looks like this:\n> \n>         sub format_paging_nav {\n>         >>>>>>>>my ($action, $hash, $head, $page, $nrevs) = @_;\n>         ...\n>         >>>>>>>>if ($page > 0) {\n>         >>>>>>>>>>>>>>>>$paging_nav .= \" &sdot; \" .\n>         >>>>>>>>>>>>>>>>>>>>>>>>$cgi->a({-href => href(action=>$a\n>         >>>>>>>>>>>>>>>>>>>>>>>>         -accesskey => \"p\", -titl\n>         >>>>>>>>} else {\n>         ...\n> \n> If your policy is to indent continuation lines (which is why you\n> have a TAB before \"$cgi->a\"), not having a TAB before the\n> continued parameter list for the $cgi->a() call look inconsistent.\n> \n> If on the other hand your policy is to align parameters to an\n> operator that are spread over multiple lines, \" &sdot; \" and\n> \"$cgi-a(...\" are left and right parameters to the string\n> concatenation operator \".\" in between them, so \"$cgi->a\" should\n> be pushed back with a run of SP starting at the column that\n> begins $paging_nav and aligned with the DQ at the beginning of\n> the \" &sdot; \" string.\n\nThat is preferred, and usually used policy, although I sometimes\nuse former to avoid too long lines.\n\nI never claimed to be perfect...\n\nNevertheless this patch for example correct situation where the\nline which should be aligned is aligned using mixture of tabs and\nspaces differing from line to line in the \"same alignment\" block.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"29675","messageId":"Pine.LNX.4.64.0610221359090.3962@g5.osdl.org","threadId":"5986","inReplyTo":"200610222236.45414.jnareb@gmail.com","subject":"Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-10-22T21:03:20Z","receivedAt":"2006-10-22T21:03:20Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 22 Oct 2006, Jakub Narebski wrote:\n> \n> To be true I do those \"whitespace cleanup\" patches when I notice\n> that something is mis-aligned for _my_ tab width (2 spaces).\n\nOh, wow.\n\nYou have clearly been damaged by some nasty GNU coding style or similar.\n\nPlease immediately turn tabs into 8 character hard-tabs, and read the \nkernel Documentation/CodingStyle document.\n\nAfter that, you may have to go to some detox unit to purge yourself of the \nhabit of 2-character indents, and I realize it will be hard and you'll \nfeel like shit for a while, but you'll be a better person for it.\n\nIt's like kicking a bad drug habit. It may be painful for a while, and you \nmight wistfully think back on the \"happy days\" when things went by in a \nhaze of unclear indentations, but really, it's worth it.\n\n\t\t\tLinus\n"},{"id":"29678","messageId":"200610222327.01840.jnareb@gmail.com","threadId":"5986","inReplyTo":"Pine.LNX.4.64.0610221359090.3962@g5.osdl.org","subject":"Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-22T21:27:01Z","receivedAt":"2006-10-22T21:27:01Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n> \n> On Sun, 22 Oct 2006, Jakub Narebski wrote:\n> > \n> > To be true I do those \"whitespace cleanup\" patches when I notice\n> > that something is mis-aligned for _my_ tab width (2 spaces).\n> \n> Oh, wow.\n> \n> You have clearly been damaged by some nasty GNU coding style or similar.\n> \n> Please immediately turn tabs into 8 character hard-tabs, and read the \n> kernel Documentation/CodingStyle document.\n\n2 character wide spaces are minimal width indent one can work with.\nAnd to reduce line width I use the minimal indent with. Yes, I know\nthat I should correct coding style instead...\n\nUsing 2 characters wide tabs for gitweb stems also from the fact\nthat I could not configure Emacs and cperl-mode to automatically\nindent with tabs (probably because many Emacsers think that\nTabsAreEvil); I should probably set some indent/offset variable\nto the tab-width value, or something...\n-- \nJakub Narebski\nPoland\n"},{"id":"29684","messageId":"7v64ec2c5c.fsf@assigned-by-dhcp.cox.net","threadId":"5986","inReplyTo":"Pine.LNX.4.64.0610221359090.3962@g5.osdl.org","subject":"Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-22T22:55:59Z","receivedAt":"2006-10-22T22:55:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> On Sun, 22 Oct 2006, Jakub Narebski wrote:\n>> \n>> To be true I do those \"whitespace cleanup\" patches when I notice\n>> that something is mis-aligned for _my_ tab width (2 spaces).\n>\n> Oh, wow.\n>\n> You have clearly been damaged by some nasty GNU coding style or similar.\n>\n> Please immediately turn tabs into 8 character hard-tabs, and read the \n> kernel Documentation/CodingStyle document.\n\nOfftopic comments.\n\nI am from old school, so a TAB to me is always equivalent to a\nrun of spaces that pads up to the next column that is dividible\nby 8, but there is one valid reason to occasionally take a look\nat your code with unusual TAB settings to catch coding style\nviolations, if you _were_ following an indentation policy that\nis different from what the kernel and git uses.\n\nAside from the textual comparison order habit (aka \"never use >\nor >= comparison operators\") that everybody hates (and I've been\ntrying not to inroduce new ones, albeit slowly), I have picked\nup two other \"unusual\" coding style habits, which I deliberately\nhave stayed away from applying to the code I write for git.\n\nThey both relate to the way the code is indented; unlike the\ntextual order comparison one, they do not affect readability to\nme that much and it is easier for me to shake them when I want\nto be.\n\nThey are:\n\n - There is no \"aligning\" between two lines, other than the case\n   in which they start with _identical_ substring.  Not just\n   that a TAB does not necessarily look the same as spaces to\n   the next display column that is divisible by 8 by everybody;\n   think about proportinal fonts.\n\n   When you take this position, there is only one thing you can\n   do when your logical line extends over more than one physical\n   lines because it is too long.  Since there is no aligning,\n   the only sensible thing to do is to indent it one level\n   deeper than the first physical line of the logical line.\n   Your indentation becomes like this:\n\n   <BOL><TAB>if (very long expression that extends over<EOL>\n   <BOL><TAB><TAB>more than one line) {<EOL>\n   <BOL><TAB><TAB>do this and do that...<EOL>\n   <BOL><TAB>}<EOL>\n\n   When you are following this principle (and git sources do not\n   and should not), viewing your code with an unusual tab width\n   is a good way to check the coding style violation.\n\n - If you have to split a long expression over multiple lines,\n   split the line _before_ a binary operator, not after, so when\n   you turn your head sideways 90 degrees, you would see the\n   parse tree of the expression:\n\n        foo = a-term\n                * (a-very-very-long-expression-term\n                        + yet-another-term);\n\n   If there _were_ alignment, this would perhaps look like this:\n\n        foo =     a-term\n                * (       a-very-very-long-expression-term\n                        + yet-another-term);\n"},{"id":"29690","messageId":"20061022233644.82685.qmail@web31806.mail.mud.yahoo.com","threadId":"5986","inReplyTo":"Pine.LNX.4.64.0610221359090.3962@g5.osdl.org","subject":"Re: [PATCH 1/4] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (2)","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-10-22T23:36:44Z","receivedAt":"2006-10-22T23:36:44Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Linus Torvalds <torvalds@osdl.org> wrote:\n> On Sun, 22 Oct 2006, Jakub Narebski wrote:\n> > \n> > To be true I do those \"whitespace cleanup\" patches when I notice\n> > that something is mis-aligned for _my_ tab width (2 spaces).\n> \n> Oh, wow.\n> \n> You have clearly been damaged by some nasty GNU coding style or similar.\n> \n> Please immediately turn tabs into 8 character hard-tabs, and read the \n> kernel Documentation/CodingStyle document.\n> \n> After that, you may have to go to some detox unit to purge yourself of the \n> habit of 2-character indents, and I realize it will be hard and you'll \n> feel like shit for a while, but you'll be a better person for it.\n> \n> It's like kicking a bad drug habit. It may be painful for a while, and you \n> might wistfully think back on the \"happy days\" when things went by in a \n> haze of unclear indentations, but really, it's worth it.\n\nFunny, but true.\n\nOne way to do it is:\n\n(defun my-perl-mode ()\n  (setq perl-indent-level 8)\n  (setq perl-continued-statement-offset 8)\n)\n\n(add-hook 'perl-mode-hook 'my-perl-mode)\n\n     Luben\n"}]}