qgadrian / elixir_git_hooks

🪝 Add git hooks to Elixir projects
MIT License
157 stars 16 forks source link

`fatal: --git-path requires an argument` #191

Open PotcFdk opened 3 months ago

PotcFdk commented 3 months ago

After installing, or when running mix git_hooks.install, I get multiple fatal: --git-path requires an argument. I believe this is because there are cases that use some git commands incorrectly.

One example that I found seems to be here: https://github.com/qgadrian/elixir_git_hooks/blob/79b9aec14dbec5f0c24d0d2dfdadc102799c1ab0/lib/git/path.ex#L23-L24 This calls resolve_git_path_based_on_git_version without any arguments. That function then seems to default to "" and hence calls git rev-parse with the relevant argument missing: https://github.com/qgadrian/elixir_git_hooks/blob/79b9aec14dbec5f0c24d0d2dfdadc102799c1ab0/lib/git/path.ex#L56-L70

Let's see what rev-parse does with --git-path but with no further arguments:

$ git rev-parse --git-path       
fatal: --git-path requires an argument

Aha. That same function, resolve_git_path_based_on_git_version, seems to also have a case that uses --git-dir. Let's see what that one does:

$ git rev-parse --git-dir 
.git

No errors there. Maybe the expected git rev-parse behavior changed?

Tested under Windows 11.

$ git version
git version 2.46.0.windows.1