提交 35f401a6 编写于 作者: J Jakub Narebski 提交者: Junio C Hamano

gitweb: Use --no-commit-id in git_commit and git_commitdiff

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: NJakub Narebski <jnareb@gmail.com>
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 af70fa4f
...@@ -3133,14 +3133,12 @@ sub git_commit { ...@@ -3133,14 +3133,12 @@ sub git_commit {
if (!defined $parent) { if (!defined $parent) {
$parent = "--root"; $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"); or die_error(undef, "Open git-diff-tree failed");
my @difftree = map { chomp; $_ } <$fd>; my @difftree = map { chomp; $_ } <$fd>;
close $fd or die_error(undef, "Reading git-diff-tree failed"); 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 # non-textual hash id's can be cached
my $expires; my $expires;
if ($hash =~ m/^[0-9a-fA-F]{40}$/) { if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
...@@ -3411,15 +3409,14 @@ sub git_commitdiff { ...@@ -3411,15 +3409,14 @@ sub git_commitdiff {
my @difftree; my @difftree;
if ($format eq 'html') { if ($format eq 'html') {
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts, open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
"--no-commit-id",
"--patch-with-raw", "--full-index", $hash_parent, $hash "--patch-with-raw", "--full-index", $hash_parent, $hash
or die_error(undef, "Open git-diff-tree failed"); or die_error(undef, "Open git-diff-tree failed");
while (chomp(my $line = <$fd>)) { while (chomp(my $line = <$fd>)) {
# empty line ends raw part of diff-tree output # empty line ends raw part of diff-tree output
last unless $line; last unless $line;
# filter out commit ID output push @difftree, $line;
push @difftree, $line
unless $line =~ m/^[0-9a-fA-F]{40}$/;
} }
} elsif ($format eq 'plain') { } elsif ($format eq 'plain') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册