{"thread":{"id":"10547","subject":"[PATCH] cvsexportcommit: fix for commits that do not have parents","startedAt":"2007-10-31T20:55:13Z","lastAt":"2007-10-31T20:55:13Z","messageCount":1,"participants":["Brad King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57731","messageId":"4728EBB1.8050404@kitware.com","threadId":"10547","inReplyTo":null,"subject":"[PATCH] cvsexportcommit: fix for commits that do not have parents","fromName":"Brad King","fromEmail":"brad.king@kitware.com","sentAt":"2007-10-31T20:55:13Z","receivedAt":"2007-10-31T20:55:13Z","isPatch":true,"sender":{"key":"brad.king@kitware.com","avatar":"https://avatars.githubusercontent.com/u/87268?v=4"},"body":"Previously commits without parents would fail to export with a\nmessage indicating that the commits had more than one parent.\nInstead we should use the --root option for git-diff-tree in\nplace of a parent.\n\nSigned-off-by: Brad King <brad.king@kitware.com>\n---\nThis is a corrected version of the patch I previously posted which had a typo.\n git-cvsexportcommit.perl |   13 ++++++++++---\n 1 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\nindex f284c88..26844af 100755\n--- a/git-cvsexportcommit.perl\n+++ b/git-cvsexportcommit.perl\n@@ -82,6 +82,7 @@ foreach my $line (@commit) {\n     }\n }\n\n+my $noparent = \"0000000000000000000000000000000000000000\";\n if ($parent) {\n     my $found;\n     # double check that it's a valid parent\n@@ -95,8 +96,10 @@ if ($parent) {\n } else { # we don't have a parent from the cmdline...\n     if (@parents == 1) { # it's safe to get it from the commit\n \t$parent = $parents[0];\n-    } else { # or perhaps not!\n-\tdie \"This commit has more than one parent -- please name the parent you want to use explicitly\";\n+    } elsif (@parents == 0) { # there is no parent\n+        $parent = $noparent;\n+    } else { # cannot choose automatically from multiple parents\n+        die \"This commit has more than one parent -- please name the parent you want to use explicitly\";\n     }\n }\n\n@@ -116,7 +119,11 @@ if ($opt_a) {\n }\n close MSG;\n\n-`git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die \"Cannot diff\";\n+if ($parent eq $noparent) {\n+    `git-diff-tree --binary -p --root $commit >.cvsexportcommit.diff`;# || die \"Cannot diff\";\n+} else {\n+    `git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die \"Cannot diff\";\n+}\n\n ## apply non-binary changes\n\n-- \n1.5.3.2\n"}]}