Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] git hooks for [e|j]git

Hi

On Tue, Nov 4, 2014 at 12:38 PM, Laurent Goubet <laurent.goubet@xxxxxxx> wrote:
You've removed the list from the discussion, was that intended?

No, sorry, my mistake. I resent to the list.


Whatever we do, we need, at one point, to determine whether the hook exists in .git/hooks, and if it does, if it is executable. That's the one test needed, and I can't se a way to make it less so. In cgit, the test is done within run-command (see http://git.kernel.org/cgit/git/git.git/tree/run-command.c#n797 ). In java, you can see how I did it in the FS implementations, namely https://git.eclipse.org/r/#/c/35476/4/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_POSIX_Java7.java and https://git.eclipse.org/r/#/c/35476/4/org.eclipse.jgit.java7/src/org/eclipse/jgit/util/FS_Win32_Java7Cygwin.java (and the sub-par https://git.eclipse.org/r/#/c/35476/4/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java for Java 5... which couldn't even check if the file is executable afaik).

Some hooks can be disabled through an option: CommitCommand#noVerify bypasses the pre-commit and commit-msg hooks (mimics cgit's "--no-verify"), CommitCommand#noPostRewrite bypasses the post-rewrite hook (mimics cgit's "--no-post-rewrite"). "post-commit", "pre-rebase" and, only on rebase, "post-rewrite" cannot be bypassed... but we can introduce new options to do so even if they don't exist in cgit. I am unsure of the impact of the simple test "isExecutable" though...

I fully agree. There is no way that we can avoid a check for .git/hooks/*. No problem with that. But you have been reading .git/COMMIT_MSG before you checked that you'll really need that data. That's and extra open&read although there may be no hooks present.

 

Back to the top