summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d47eed3)
raw | patch | inline | side by side (parent: d47eed3)
author | Shawn O. Pearce <spearce@spearce.org> | |
Thu, 9 Aug 2007 06:38:16 +0000 (02:38 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 10 Aug 2007 08:00:25 +0000 (01:00 -0700) |
We have to load a tree difference for the purpose of testing
file patterns. But if our branch is being created and there is no
specific base to difference against in the rule our base will be
'0'x40. This is (usually) not a valid tree-ish object in a Git
repository, so there's nothing to difference against.
Instead of creating the empty tree and running git-diff against
that we just take the output of `ls-tree -r --name-only` and mark
every returned pathname as an add.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
file patterns. But if our branch is being created and there is no
specific base to difference against in the rule our base will be
'0'x40. This is (usually) not a valid tree-ish object in a Git
repository, so there's nothing to difference against.
Instead of creating the empty tree and running git-diff against
that we just take the output of `ls-tree -r --name-only` and mark
every returned pathname as an add.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/hooks/update-paranoid | patch | blob | history |
index 84ed4524803b4662f2c1a0ff336bcfb1966d2c0d..068fa3708331bbb7d451040715c8bba9623f8c7e 100644 (file)
my $d = $diff_cache{$base};
unless ($d) {
local $/ = "\0";
- open(T,'-|','git','diff-tree',
- '-r','--name-status','-z',
- $base,$new) or return undef;
my %this_diff;
- while (<T>) {
- my $op = $_;
- chop $op;
+ if ($base =~ /^0{40}$/) {
+ open(T,'-|','git','ls-tree',
+ '-r','--name-only','-z',
+ $new) or return undef;
+ while (<T>) {
+ chop;
+ $this_diff{$_} = 'A';
+ }
+ close T or return undef;
+ } else {
+ open(T,'-|','git','diff-tree',
+ '-r','--name-status','-z',
+ $base,$new) or return undef;
+ while (<T>) {
+ my $op = $_;
+ chop $op;
- my $path = <T>;
- chop $path;
+ my $path = <T>;
+ chop $path;
- $this_diff{$path} = $op;
+ $this_diff{$path} = $op;
+ }
+ close T or return undef;
}
- close T or return undef;
$d = \%this_diff;
$diff_cache{$base} = $d;
}