git/list[1] front-page[2] threads[3] people[4] search[5] about
 

misc. gitweb patches (directories first, …)

From
Thorsten Glaser <tg@debian.org>
Date
Feb 28, 2025, 06:31 UTC
Message-ID
<a9673d0b-4698-fc68-1a80-10940c4a8330@debian.org>
Hi again²,

and while at it, why not feed the remainder of my local gitweb patches to you in the hope they can be applied.

The two extra comments are to not desynchronise the syntax highlighting of my editor (jupp) which mis-interprets the presence of that unescaped double quote in the regex before.

The other hunk is to render subdirectories before files in a directory, as is prudent and expected, on Unix at least. It may not be the most efficient way to do this (I’m not a Perl programmer, but willing to learn) though does the job.

diff --git a/src/plugins/scmgit/cgi-bin/gitweb.cgi b/src/plugins/scmgit/cgi-bin/gitweb.cgi
index c81eef0e5d..909d55792a 100755
--- a/src/plugins/scmgit/cgi-bin/gitweb.cgi
+++ b/src/plugins/scmgit/cgi-bin/gitweb.cgi
@@ -5436,7 +5437,7 @@ sub git_patchset_body {
 	while ($patch_line) {
 
 		# parse "git diff" header line
-		if ($patch_line =~ m/^diff --git (\"(?:[^\\\"]*(?:\\.[^\\\"]*)*)\"|[^ "]*) (.*)$/) {
+		if ($patch_line =~ m/^diff --git (\"(?:[^\\\"]*(?:\\.[^\\\"]*)*)\"|[^ "]*) (.*)$/) {  #"
 			# $1 is from_name, which we do not use
 			$to_name = unquote($2);
 			$to_name =~ s!^b/!!;
@@ -7287,8 +7288,26 @@ sub git_tree {
 
 		print "</tr>\n";
 	}
+	# directories first
 	foreach my $line (@entries) {
 		my %t = parse_ls_tree_line($line, -z => 1, -l => $show_sizes);
+		next unless ($t{'type'} eq "tree");
+
+		if ($alternate) {
+			print "<tr class=\"dark\">\n";
+		} else {
+			print "<tr class=\"light\">\n";
+		}
+		$alternate ^= 1;
+
+		git_print_tree_entry(\%t, $basedir, $hash_base, $have_blame);
+
+		print "</tr>\n";
+	}
+	# then nōn-directories
+	foreach my $line (@entries) {
+		my %t = parse_ls_tree_line($line, -z => 1, -l => $show_sizes);
+		next if ($t{'type'} eq "tree");
 
 		if ($alternate) {
 			print "<tr class=\"dark\">\n";
@@ -7422,7 +7441,7 @@ sub git_snapshot {
 		$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});
 	}
 
-	$filename =~ s/(["\\])/\\$1/g;
+	$filename =~ s/(["\\])/\\$1/g;  #"
 	my %latest_date;
 	if (%co) {
 		%latest_date = parse_date($co{'committer_epoch'}, $co{'committer_tz'});


bye,
//mirabilos
-- 
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
	-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)
Message 1 of 1 in “misc. gitweb patches (directories first, …)”
  1. Thorsten GlaserFeb 28, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.