Reputation: 71
I am writing a git pre-receive hook in python and would like to receive the arguments passed from the command line in the push-option.
git push -push-option='my option'
How do I access the push option inside of my pre-receive hook?
Upvotes: 4
Views: 1211
Reputation: 557
See the githook documentation.
The number of push options given on the command line of
git push --push-option=...
can be read from the environment variableGIT_PUSH_OPTION_COUNT
, and the options themselves are found inGIT_PUSH_OPTION_0
,GIT_PUSH_OPTION_1
,… If it is negotiated to not use the push options phase, the environment variables will not be set. If the client selects to use push options, but doesn’t transmit any, the count variable will be set to zero,GIT_PUSH_OPTION_COUNT=0
.
Upvotes: 7