]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Use --no-commit-id in git_commit and git_commitdiff
authorJakub Narebski <redacted>
Thu, 26 Oct 2006 08:50:20 +0000 (10:50 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:11 +0000 (00:07 -0400)
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). Remove
filtering commit IDs from git-diff-tree output.

This option is in git since at least v1.0.0, so make use of it.

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

index 4c1e54d893bd71ebe93a3672744283fe138384d126444504552332079d48ecde..71068ddc3c43457c59d5e469dd6a43db7bd1f9729c1b0fdd301ce6a6d6df7b8f 100755 (executable)
@@ -3223,14 +3223,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}$/) {
@@ -3501,15 +3499,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') {
This page took 0.245224 seconds and 4 git commands to generate.