Code

git-svn: understand grafts when doing dcommit
authorEric Wong <normalperson@yhbt.net>
Sat, 8 Sep 2007 23:33:08 +0000 (16:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 Sep 2007 09:30:33 +0000 (02:30 -0700)
Use the rev-list --parents functionality to read the parents
of the commit.  cat-file only shows the raw object with the
original parents and doesn't take into account grafts; so
we'll rely on rev-list machinery for the smarts here.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-svn.perl

index fbd4691bc52a91b408c73e119fcddcab6454b70a..f8181609f942b22dc95992740326e8b5788feba5 100755 (executable)
@@ -841,14 +841,9 @@ sub working_head_info {
 
 sub read_commit_parents {
        my ($parents, $c) = @_;
-       my ($fh, $ctx) = command_output_pipe(qw/cat-file commit/, $c);
-       while (<$fh>) {
-               chomp;
-               last if '';
-               /^parent ($sha1)/ or next;
-               push @{$parents->{$c}}, $1;
-       }
-       close $fh; # break the pipe
+       chomp(my $p = command_oneline(qw/rev-list --parents -1/, $c));
+       $p =~ s/^($c)\s*// or die "rev-list --parents -1 $c failed!\n";
+       @{$parents->{$c}} = split(/ /, $p);
 }
 
 sub linearize_history {