Skip to content

$1 necessity in commit-msg hook #1108

Discussion options

You must be logged in to vote

I investigated in the git source code and it seems like $1 always ends with /COMMIT_EDITMSG.

The .git directory can be configured so the directory path may be different. I haven't worked with submodules enough but perhaps this is can be different for submodules too, as you speculate.

Anyway, it should be safe to assume .git/COMMIT_EDITMSG as long as you're not changing the .git directory.

Investigation

  1. The commit-msg commit hook is called here with argument git_path_commit_editmsg():
    https://github.com/git/git/blob/715d08a9e51251ad8290b181b6ac3b9e1f9719d7/builtin/commit.c#L1088

  2. git_path_commit_editmsg is defined using GIT_PATH_FUNC here:
    https://github.com/git/git/blob/715d08a9e51251a…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@typicode
Comment options

Comment options

You must be logged in to vote
1 reply
@typicode
Comment options

Answer selected by privatenumber
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants