{"thread":{"id":"63022","subject":"misc. gitweb patches (directories first, …)","startedAt":"2025-02-28T06:31:17Z","lastAt":"2025-02-28T06:31:17Z","messageCount":1,"participants":["Thorsten Glaser"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"513229","messageId":"a9673d0b-4698-fc68-1a80-10940c4a8330@debian.org","threadId":"63022","inReplyTo":null,"subject":"misc. gitweb patches (directories first, …)","fromName":"Thorsten Glaser","fromEmail":"tg@debian.org","sentAt":"2025-02-28T06:31:15Z","receivedAt":"2025-02-28T06:31:17Z","isPatch":false,"sender":{"key":"tg@debian.org","avatar":"https://avatars.githubusercontent.com/u/861078?v=4"},"body":"Hi again²,\n\nand while at it, why not feed the remainder of my local gitweb\npatches to you in the hope they can be applied.\n\nThe two extra comments are to not desynchronise the syntax\nhighlighting of my editor (jupp) which mis-interprets the\npresence of that unescaped double quote in the regex before.\n\nThe other hunk is to render subdirectories before files in\na directory, as is prudent and expected, on Unix at least.\nIt may not be the most efficient way to do this (I’m not a\nPerl programmer, but willing to learn) though does the job.\n\ndiff --git a/src/plugins/scmgit/cgi-bin/gitweb.cgi b/src/plugins/scmgit/cgi-bin/gitweb.cgi\nindex c81eef0e5d..909d55792a 100755\n--- a/src/plugins/scmgit/cgi-bin/gitweb.cgi\n+++ b/src/plugins/scmgit/cgi-bin/gitweb.cgi\n@@ -5436,7 +5437,7 @@ sub git_patchset_body {\n \twhile ($patch_line) {\n \n \t\t# parse \"git diff\" header line\n-\t\tif ($patch_line =~ m/^diff --git (\\\"(?:[^\\\\\\\"]*(?:\\\\.[^\\\\\\\"]*)*)\\\"|[^ \"]*) (.*)$/) {\n+\t\tif ($patch_line =~ m/^diff --git (\\\"(?:[^\\\\\\\"]*(?:\\\\.[^\\\\\\\"]*)*)\\\"|[^ \"]*) (.*)$/) {  #\"\n \t\t\t# $1 is from_name, which we do not use\n \t\t\t$to_name = unquote($2);\n \t\t\t$to_name =~ s!^b/!!;\n@@ -7287,8 +7288,26 @@ sub git_tree {\n \n \t\tprint \"</tr>\\n\";\n \t}\n+\t# directories first\n \tforeach my $line (@entries) {\n \t\tmy %t = parse_ls_tree_line($line, -z => 1, -l => $show_sizes);\n+\t\tnext unless ($t{'type'} eq \"tree\");\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+\n+\t\tgit_print_tree_entry(\\%t, $basedir, $hash_base, $have_blame);\n+\n+\t\tprint \"</tr>\\n\";\n+\t}\n+\t# then nōn-directories\n+\tforeach my $line (@entries) {\n+\t\tmy %t = parse_ls_tree_line($line, -z => 1, -l => $show_sizes);\n+\t\tnext if ($t{'type'} eq \"tree\");\n \n \t\tif ($alternate) {\n \t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n@@ -7422,7 +7441,7 @@ sub git_snapshot {\n \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n \t}\n \n-\t$filename =~ s/([\"\\\\])/\\\\$1/g;\n+\t$filename =~ s/([\"\\\\])/\\\\$1/g;  #\"\n \tmy %latest_date;\n \tif (%co) {\n \t\t%latest_date = parse_date($co{'committer_epoch'}, $co{'committer_tz'});\n\n\nbye,\n//mirabilos\n-- \n„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,\nmksh auf jedem System zu installieren.“\n\t-- XTaran auf der OpenRheinRuhr, ganz begeistert\n(EN: “[…]uhr.gz is a reason to install mksh on every system.”)\n"}]}