]> source.dussan.org Git - jgit.git/commitdiff
Set expected old object id to all zeros when head id is null 55/4755/2
authorKevin Sawicki <kevin@github.com>
Wed, 7 Dec 2011 02:02:30 +0000 (18:02 -0800)
committerKevin Sawicki <kevin@github.com>
Wed, 7 Dec 2011 02:02:30 +0000 (18:02 -0800)
This will be the case on the initial commit to a repository
and the ref update should expect a non-existent ref

Change-Id: Iaa06e47e6e8cc4a0281c7683b367d4806dd980ea

org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

index fc56f9af1184b4bd15d7dea619d0c450460be997..14a7494ba62fd8d20c58f4d033230c0f84e970ba 100644 (file)
@@ -228,7 +228,10 @@ public class CommitCommand extends GitCommand<RevCommit> {
                                                        ru.setRefLogMessage(
                                                                        prefix + revCommit.getShortMessage(), false);
                                                }
-                                               ru.setExpectedOldObjectId(headId);
+                                               if (headId != null)
+                                                       ru.setExpectedOldObjectId(headId);
+                                               else
+                                                       ru.setExpectedOldObjectId(ObjectId.zeroId());
                                                Result rc = ru.forceUpdate();
                                                switch (rc) {
                                                case NEW: