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

[PATCH 4/3] gitweb: Use --no-commit-id in git_commit and git_commitdiff

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 25, 2006, 12:17 UTC
Message-ID
<200610251417.20076.jnareb@gmail.com>
In-Reply-To
<200610241354.49396.jnareb@gmail.com>

Use --no-commit-id option to git diff-tree command in git_commit and git_commitdiff to filter out commit ID output that git-diff-tree adds when called with only one <tree-ish> (not only for --stdin).

This option is in git since at least v1.0.0, so make use of it.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Gaaah, --no-commit-id is at least since v1.0.0, and we do require
--full-history and --git-dir options which are much later additions.
This is "correction" patch.
 gitweb/gitweb.perl |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e35ecb4..345e336 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3004,14 +3004,12 @@ sub git_commit {
 	if (!defined $parent) {
 		$parent = "--root";
 	}
-	open my $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, $parent, $hash
+	open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
+		@diff_opts, $parent, $hash
 		or die_error(undef, "Open git-diff-tree failed");
 	my @difftree = map { chomp; $_ } <$fd>;
 	close $fd or die_error(undef, "Reading git-diff-tree failed");
 
-	# filter out commit ID output
-	@difftree = grep(!/^[0-9a-fA-F]{40}$/, @difftree);
-
 	# non-textual hash id's can be cached
 	my $expires;
 	if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
@@ -3324,15 +3322,14 @@ sub git_commitdiff {
 	my @difftree;
 	if ($format eq 'html') {
 		open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
+			"--no-commit-id",
 			"--patch-with-raw", "--full-index", $hash_parent, $hash
 			or die_error(undef, "Open git-diff-tree failed");
 
 		while (chomp(my $line = <$fd>)) {
 			# empty line ends raw part of diff-tree output
 			last unless $line;
-			# filter out commit ID output
-			push @difftree, $line
-				unless $line =~ m/^[0-9a-fA-F]{40}$/;
+			push @difftree, $line;
 		}
 
 	} elsif ($format eq 'plain') {
-- 
1.4.2.1
Previous: Jakub NarebskiNext: Jakub Narebski
Message 6 of 8 in “gitweb: Improvements to commitdiff oview”
  1. 0/3 gitweb: Improvements to commitdiff oviewJakub Narebski, Oct 24, 2006
  2. 1/3 gitweb: Get rid of git_print_simplified_logJakub Narebski, Oct 24, 2006
  3. 2/3 gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiffJakub Narebski, Oct 24, 2006
  4. Junio C HamanoOct 25, 2006
  5. Jakub NarebskiOct 25, 2006
  6. 4/3 gitweb: Use --no-commit-id in git_commit and git_commitdiffJakub Narebski, Oct 25, 2006
  7. 2/3 gitweb: Use --no-commit-id in git_commit and git_commitdiffJakub Narebski, Oct 25, 2006
  8. 3/3 gitweb: Print commit message without title in commitdiff only if there is anyJakub Narebski, Oct 24, 2006

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.