summaryrefslogtreecommitdiff
path: root/templates/hooks--pre-push.sample
AgeCommit message (Collapse)Author
2020-09-23hooks--pre-push.sample: use hash-agnostic zero OIDDenton Liu
The pre-push sample hook has the zero OID hardcoded as 40 zeros. However, with the introduction of SHA-256 support, this assumption no longer holds true. Replace the hardcoded $z40 with a call to git hash-object --stdin </dev/null | tr '[0-9a-f]' '0' so the sample hook becomes hash-agnostic. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-23hooks--pre-push.sample: modernize scriptDenton Liu
The preferred form for a command substitution is $() over ``. Use this form for the command substitution in the sample hook. The preferred form for conditional tests is to use `test` over []. Replace [] with `test`. Finally, replace all instances of "sha" with "oid". Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-22pre-push.sample: remove unnecessary and misleading IFS=' 'Jim Hill
The sample hook explicitly sets IFS to SP and nothing else so that the "read" used in the per-ref while loop that iterates over "<localref> SP <localsha1> SP <remoteref> SP <remotesha>" records, where we know refs and sha1s will not have SPs, would split them correctly. While this is not wrong per-se, it is not necessary; because we know these fields do not contain HT or LF, either, we can simply leave IFS the default. This will also prevent those who cut and paste from this sample from getting bitten when they write things in the per-ref loop that need splitting with the default $IFS (e.g. use $(git rev-list ...) to produce one-record-per-line output). Signed-off-by: Jim Hill <gjthill@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-11pre-push.sample: Write error message to stderrW. Trevor King
githooks(5) suggests: Information about why the push is rejected may be sent to the user by writing to standard error. So follow that advice in the sample. Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-30fix shell syntax error in templateThorsten Glaser
An if clause must not be empty; add a "colon" command. Signed-off-by: Thorsten Glaser <t.glaser@tarent.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-11pre-push.sample: Make the script executableWieland Hoffmann
githooks(5) says that "[...]the .sample files are executable by default" which was not true. Signed-off-by: Wieland Hoffmann <themineo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-18Add sample pre-push hook scriptAaron Schrab
Create a sample of a script for a pre-push hook. The main purpose is to illustrate how a script may parse the information which is supplied to such a hook. The script may also be useful to some people as-is for avoiding to push commits which are marked as a work in progress. Signed-off-by: Aaron Schrab <aaron@schrab.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>