]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff
authorJakub Narebski <redacted>
Tue, 24 Oct 2006 11:54:49 +0000 (13:54 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:11 +0000 (00:07 -0400)
Filter out commit ID output that git-diff-tree adds when called with
only one <tree-ish> (not only for --stdin) in git_commit and
git_commitdiff.

This also works with older git versions, which doesn't have
--no-commit-id option to git-diff-tree.

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index b34b75d4b4d536178ab520de20395ce2af77d79ff9444cef12febf4b5e44bdb4..404ee6d8ab9ebde38a2e367b732e7fe8b73adeb4c31867ed868ba5056da6f0e8 100755 (executable)
@@ -3136,6 +3136,9 @@ sub git_commit {
        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}$/) {
@@ -3412,7 +3415,9 @@ sub git_commitdiff {
                while (chomp(my $line = <$fd>)) {
                        # empty line ends raw part of diff-tree output
                        last unless $line;
-                       push @difftree, $line;
+                       # filter out commit ID output
+                       push @difftree, $line
+                               unless $line =~ m/^[0-9a-fA-F]{40}$/;
                }
 
        } elsif ($format eq 'plain') {
This page took 0.230358 seconds and 4 git commands to generate.