From c96b40d5921d68edb96afad38b9c171388af4e05 Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Sun, 7 Oct 2012 17:13:18 +0200 Subject: CommitCommand: Don't allow amending on initial commit Change-Id: I27b13510eb6756da21d0d359d76031da4a875e28 --- .../tst/org/eclipse/jgit/api/CommitCommandTest.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'org.eclipse.jgit.test') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java index 44f1a48c31..3729387f32 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java @@ -50,6 +50,7 @@ import static org.junit.Assert.assertTrue; import java.io.File; import java.util.List; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.lib.ConfigConstants; @@ -420,4 +421,10 @@ public class CommitCommandTest extends RepositoryTestCase { assertEquals("commit: Squashed commit of the following:", db .getReflogReader(db.getBranch()).getLastEntry().getComment()); } + + @Test(expected = WrongRepositoryStateException.class) + public void commitAmendOnInitialShouldFail() throws Exception { + Git git = new Git(db); + git.commit().setAmend(true).setMessage("initial commit").call(); + } } -- cgit v1.2.3