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 --- org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java | 4 ++++ org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java | 1 + 2 files changed, 5 insertions(+) (limited to 'org.eclipse.jgit/src/org/eclipse/jgit') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index ae6d62963e..87c282d110 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -176,6 +176,10 @@ public class CommitCommand extends GitCommand { // determine the current HEAD and the commit it is referring to ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); + if (headId == null && amend) + throw new WrongRepositoryStateException( + JGitText.get().commitAmendOnInitialNotPossible); + if (headId != null) if (amend) { RevCommit previousCommit = new RevWalk(repo) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index d70481450c..0c0ece7d10 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -146,6 +146,7 @@ public class JGitText extends TranslationBundle { /***/ public String commitAlreadyExists; /***/ public String commitMessageNotSpecified; /***/ public String commitOnRepoWithoutHEADCurrentlyNotSupported; + /***/ public String commitAmendOnInitialNotPossible; /***/ public String compressingObjects; /***/ public String connectionFailed; /***/ public String connectionTimeOut; -- cgit v1.2.3