@matheusbsbs / matheus-bagliano / commits / 62fae51dd5
Fork 0

gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff

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 <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Oct 24, 2006 at 13:54 UTC 62fae51dd57b36cfbb25c9ade539ea5a6ef5ad84
1 file changed +6 -1
gitweb/gitweb.perl
+6 -1
@@ -3115,6 +3115,9 @@ sub git_commit {
3115 my @difftree = map { chomp; $_ } <$fd>;
3116 close $fd or die_error(undef, "Reading git-diff-tree failed");
3117
3118 + # filter out commit ID output
3119 + @difftree = grep(!/^[0-9a-fA-F]{40}$/, @difftree);
3120 +
3121 # non-textual hash id's can be cached
3122 my $expires;
3123 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
@@ -3391,7 +3394,9 @@ sub git_commitdiff {
3394 while (chomp(my $line = <$fd>)) {
3395 # empty line ends raw part of diff-tree output
3396 last unless $line;
3394 - push @difftree, $line;
3397 + # filter out commit ID output
3398 + push @difftree, $line
3399 + unless $line =~ m/^[0-9a-fA-F]{40}$/;
3400 }
3401
3402 } elsif ($format eq 'plain') {