Community
Participate
Working Groups
I am the author of a precommit formatting library (https://github.com/Cosium/git-code-format-maven-plugin/). The hook formats the staged files. Everything works fine except when using commit 'all' option. With the classic git cli 'git commit -a' works fine. But with jGit, the hook is triggered before adding the files to staging: ``` if (!noVerify) { Hooks.preCommit(repo, hookOutRedirect.get(PreCommitHook.NAME), hookErrRedirect.get(PreCommitHook.NAME)) .call(); } processOptions(state, rw); if (all && !repo.isBare()) { try (Git git = new Git(repo)) { git.add().addFilepattern(".") //$NON-NLS-1$ .setUpdate(true).call(); } catch (NoFilepatternException e) { // should really not happen throw new JGitInternalException(e.getMessage(), e); } } ``` Because of that, the hook does not see any staged file and therefore does not format them. I think that the files should be added to staging before hooks precommit execution.