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

git hook question

From
Wesley Schwengle <wesleys@opperschaap.net>
Date
May 29, 2026, 05:01 UTC
Message-ID
<cc9fda14-d8e8-4982-9a3d-9aa816c0b90c@opperschaap.net>
Hello,
I added the following to my gitconfig:

hook.npm-test.event=pre-push hook.npm-test.command=npm run test

This works well when I run `git hook run pre-push' but when using `git push' this breaks a little because it adds the remote and the location, as seen via `GIT_TRACE=1 git push origin':

00:46:53.714453 run-command.c:673 trace: run_command: 'npm run test' origin git@gitlab.com:waterkip/mything.git 00:46:53.714458 run-command.c:765 trace: start_command: /bin/sh -c 'npm run test "$@"' 'npm run test' origin git@gitlab.com:waterkip/mything.git

I understand the why, normally pre-push gets `<local-ref> SP <local-object-name> SP <remote-ref> SP <remote-object-name> LF'. This has a similar feel, albeit a different syntax. The difference feels like a minor bug, but not one I'm worried about at this moment: you would expect it to get the same arguments/parameters as the regular pre-push hook. But I digress.

My actual question is: Is there a way to tell the hook "Don't give me arguments, just run the plain command that is defined". I looked in `man 1 git-hook', but I was unable to find something that looks like it.

Cheers, Wesley

-- 
Wesley Schwengle
Next: Jeff King
Message 1 of 10 in “git hook question”
  1. Wesley SchwengleMay 29, 2026
  2. Jeff KingMay 29, 2026
  3. Wesley SchwengleMay 29, 2026
  4. WesleyMay 29, 2026
  5. Ben KnobleMay 29, 2026
  6. Jeff KingMay 29, 2026
  7. Junio C HamanoJun 1, 2026
  8. Jeff KingJun 1, 2026
  9. Jeff KingMay 29, 2026
  10. Adrian RatiuJun 3, 2026

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.