git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/4] pre-push hook support

From
Aaron Schrab <aaron@schrab.com>
Date
Dec 28, 2012, 22:57 UTC
Message-ID
<1356735452-21667-1-git-send-email-aaron@schrab.com>

There have been at least a couple of submissions to add support for a pre-push hook, which were rejected at least partially because they didn't provide enough information to a hook script for it to determine what was to be pushed any better than a separate wrapper around the 'git push' command would be able to do. In this series I attempt to address that problem.

The first two patches in this series do a little bit of refactoring in order to make it easier to call hooks with a variable number of arguments.

The third patch actually adds support for calling a pre-push hook. If it exists, it will be called with the name and URL of the destination remote (if a named remote isn't being used, the URL will be supplied for both) followed by another argument for each ref being pushed; these arguments take the form:

  <local ref>:<local sha1>:<remote ref>:<remote sha1>

This should provide enough information for a script to easily determine the set of commits that is being pushed, and thus make a decision if that should be allowed.

The final patch adds a sample pre-push hook script which will deny attempts to push commits that are marked as a work in progress.

Aaron Schrab (4):
  hooks: Add function to check if a hook exists
  hooks: support variable number of parameters
  push: Add support for pre-push hooks
  Add sample pre-push hook script
 Documentation/githooks.txt       |   28 ++++++++
 builtin/push.c                   |    1 +
 run-command.c                    |   35 ++++++---
 run-command.h                    |    3 +
 t/t5571-pre-push-hook.sh         |  145 ++++++++++++++++++++++++++++++++++++++
 templates/hooks--pre-push.sample |   63 +++++++++++++++++
 transport.c                      |   25 +++++++
 transport.h                      |    1 +
 8 files changed, 292 insertions(+), 9 deletions(-)
 create mode 100755 t/t5571-pre-push-hook.sh
 create mode 100644 templates/hooks--pre-push.sample
-- 
1.7.10.4
Next: Aaron Schrab
Message 1 of 22 in “pre-push hook support”
  1. 0/4 pre-push hook supportAaron Schrab, Dec 28, 2012
  2. 1/4 hooks: Add function to check if a hook existsAaron Schrab, Dec 28, 2012
  3. Junio C HamanoDec 29, 2012
  4. Aaron SchrabDec 29, 2012
  5. Junio C HamanoDec 29, 2012
  6. 2/4 hooks: support variable number of parametersAaron Schrab, Dec 28, 2012
  7. 3/4 push: Add support for pre-push hooksAaron Schrab, Dec 28, 2012
  8. 4/4 Add sample pre-push hook scriptAaron Schrab, Dec 28, 2012
  9. Junio C HamanoDec 29, 2012
  10. Aaron SchrabDec 29, 2012
  11. Junio C HamanoDec 29, 2012
  12. 0/3 pre-push hook supportAaron Schrab, Jan 13, 2013
  13. 1/3 hooks: Add function to check if a hook existsAaron Schrab, Jan 13, 2013
  14. 2/3 push: Add support for pre-push hooksAaron Schrab, Jan 13, 2013
  15. Junio C HamanoJan 14, 2013
  16. Junio C HamanoJan 15, 2013
  17. Junio C HamanoJan 15, 2013
  18. 3/3 Add sample pre-push hook scriptAaron Schrab, Jan 13, 2013
  19. Junio C HamanoJan 14, 2013
  20. Junio C HamanoJan 14, 2013
  21. Junio C HamanoJan 14, 2013
  22. Junio C HamanoJan 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.