user9224574
user9224574

Reputation: 71

git push option in pre receive hook

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

Answers (1)

Ben Harris
Ben Harris

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 variable GIT_PUSH_OPTION_COUNT, and the options themselves are found in GIT_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

Related Questions