Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PotcFdk opened this issue Aug 2, 2024 · 1 comment
Open

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

PotcFdk opened this issue Aug 2, 2024 · 1 comment

Comments

@PotcFdk
Copy link

PotcFdk commented Aug 2, 2024

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:

repo_path =
resolve_git_path_based_on_git_version()

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:
defp resolve_git_path_based_on_git_version(dir \\ "") do
Git.git_version()
|> Version.compare(Version.parse!("2.10.0"))
|> case do
:lt ->
"git"
|> System.cmd(["rev-parse", "--git-dir", dir])
|> build_git_path()
_gt_or_eq ->
"git"
|> System.cmd(["rev-parse", "--git-path", dir])
|> build_git_path()
end
end

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
@qgadrian
Copy link
Owner

qgadrian commented Nov 29, 2024

Update on this, I published in hex.pm a new v0.8.0-pre2 release that hopefully resolves this issue.

I will wait to get some feedback before publishing a production release.

See this comment for more technical details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants