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

Now that you mention it... I do change the behavior slightly. I've decided to check for the existence of a hook only when running it (hook present on not, I try to run it, so I prepare its arguments beforehand). The argument for the "commit-msg" hook is the path to a file containing the proposed commit message (.git/COMMIT_EDITMSG), so that the hook can change it. To run this hook, I thus serialize the message, run the hook if it is present, then re-read the commit message file. I initially did that to minimize I/O operations involving the hooks... but I didn't realize I did generate more I/O that way for that particular hook (especially in the case where it is not present...). I'll change my implementation.

I would think about that decision. JGit is highly performance optimized in some areas. You can compute in Java what you want, but file I/O should be done only when you are sure you have to do it. I would really never open a file, check for it's existence or read the file content without definitely knowing you have to. You may think that this is not very relevant for the CommitCommand since in EGit that's a seldom operation and even server side Gerrit may not create commits too often. But people use JGit e.g. to write tools rewriting history of a repos. Such tools fire hundreds of thousands of CommitCommmand.call() as fast as they can. They would suffer from extra and unnecessary file IO.



Back to the top