@matheusbsbs / matheus-bagliano / commits / 6b6012e6ca
Fork 0

cvsexportcommit: fix for commits that do not have parents

Previously commits without parents would fail to export with a message indicating that the commits had more than one parent. Instead we should use the --root option for git-diff-tree in place of a parent. Signed-off-by: Brad King <brad.king@kitware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brad King committed Oct 31, 2007 at 16:55 UTC 6b6012e6ca628a00d2e0fa6f686017f9e2d66203
1 file changed +10 -3
git-cvsexportcommit.perl
+10 -3
@@ -87,6 +87,7 @@ foreach my $line (@commit) {
87 }
88 }
89
90 +my $noparent = "0000000000000000000000000000000000000000";
91 if ($parent) {
92 my $found;
93 # double check that it's a valid parent
@@ -100,8 +101,10 @@ if ($parent) {
101 } else { # we don't have a parent from the cmdline...
102 if (@parents == 1) { # it's safe to get it from the commit
103 $parent = $parents[0];
103 - } else { # or perhaps not!
104 - die "This commit has more than one parent -- please name the parent you want to use explicitly";
104 + } elsif (@parents == 0) { # there is no parent
105 + $parent = $noparent;
106 + } else { # cannot choose automatically from multiple parents
107 + die "This commit has more than one parent -- please name the parent you want to use explicitly";
108 }
109 }
110
@@ -121,7 +124,11 @@ if ($opt_a) {
124 }
125 close MSG;
126
124 -`git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff";
127 +if ($parent eq $noparent) {
128 + `git-diff-tree --binary -p --root $commit >.cvsexportcommit.diff`;# || die "Cannot diff";
129 +} else {
130 + `git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff";
131 +}
132
133 ## apply non-binary changes
134