Is there a way to save a configuration so that a hook may work differently depending on that configuration?
I wanted to be able to make a hook that works differently depending of the value of a configuration.
One of the things I wanted to change is the pre-commit hook. Depending on the configuration, I want to change the program exit number when errors were detected (for the reasons that hook looks for). If the configuration values to false, I want to always exit with 0, if the value is true, then I want to exit with 1 if errors were detected. How can this be made possible?
Note: I want this to be usable with Git GUI, so no input while the hook is working asking what to do.
I’m not sure exactly what you’re asking, so please let me know if this answer misses the mark.
You are free to store custom configuration values in the git configuration file. For example, this sets the value of
myapp.somevariabletothis is a test:And I can retrieve that value in a script by calling
git config:So you can certainly store a persistent configuration with the repository and use that configuration in your hook scripts to modify their behavior.