checkCallable();
Collections.sort(only);
RepositoryState state = repo.getRepositoryState();
if (!state.canCommit())
throw new WrongRepositoryStateException(MessageFormat.format(
JGitText.get().cannotCommitOnARepoWithState, state.name()));
processOptions(state);
try {
if (all && !repo.isBare() && repo.getWorkTree() != null) {
Git git = new Git(repo);
try {
git.add()
.addFilepattern(".") //$NON-NLS-1$
.setUpdate(true).call();
} catch (NoFilepatternException e) {
// should really not happen
throw new JGitInternalException(e.getMessage(), e);
}
}
Ref head = repo.getRef(Constants.HEAD);
if (head == null)
throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
// determine the current HEAD and the commit it is referring to
ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
if (headId == null && amend)
throw new WrongRepositoryStateException(
JGitText.get().commitAmendOnInitialNotPossible);
if (headId != null)
if (amend) {
RevCommit previousCommit = new RevWalk(repo)