Code

git-svn: error out from dcommit on a parent-less commit
authorEric Wong <normalperson@yhbt.net>
Thu, 23 Nov 2006 22:54:03 +0000 (14:54 -0800)
committerJunio C Hamano <junkio@cox.net>
Thu, 23 Nov 2006 23:17:43 +0000 (15:17 -0800)
dcommit would unconditionally append "~1" to a commit in order
to generate a diff.  Now we generate a meaningful error message
if we try to generate an impossible diff.

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

index 80b7b87f0f4f1933e551439ca4fb2cd68981a029..f0db4af58c69f6f542552651dcde02be02905f3b 100755 (executable)
@@ -589,6 +589,13 @@ sub dcommit {
        chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..HEAD"));
        my $last_rev;
        foreach my $d (reverse @refs) {
+               if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
+                       die "Commit $d\n",
+                           "has no parent commit, and therefore ",
+                           "nothing to diff against.\n",
+                           "You should be working from a repository ",
+                           "originally created by git-svn\n";
+               }
                unless (defined $last_rev) {
                        (undef, $last_rev, undef) = cmt_metadata("$d~1");
                        unless (defined $last_rev) {