github / git-sizer

Compute various size metrics for a Git repository, flagging those that might cause problems
MIT License
3.48k stars 139 forks source link

error: couldn't open Git repository: git rev-parse failed: Unknown option: -C #79

Closed antonellagarzilli closed 3 years ago

antonellagarzilli commented 3 years ago

I am in a folder containing my git repository and when run git-sizer I get the error in the subject. compiled with make on Linux_x86_64

mhagger commented 3 years ago

That's strange. I think that the only time we use that option is when running

git -C . rev-parse --git-dir

The -C option seems to have been supported by git since very old versions. So my suspicion is that the thing that is getting run is not standard git itself but rather some wrapper script or something that doesn't handle that option.

Which version of git-sizer are you using?

What happens if you type which -a git in the repository directory? What version of Git does it find? Is it possibly a script or something that doesn't pass all arguments through? What happens if you run the above rev-parse command in the repository directory?

If none of those steps gives a clue, another possibility would be to run git-sizer under strace to see exactly what command execution is provoking the problem.

antonellagarzilli commented 3 years ago

The output of which -a git is /usr/bin/git and version is git version 1.8.3.1. The version of git-sizer is git-sizer build v1.4.0.

I have run strace, I have only found epoll_pwait(4, error: couldn't open Git repository: git rev-parse failed: Unknown option: -C, I can show you the full output of strace if needed.

mhagger commented 3 years ago

Thanks for the additional info.

I have run strace, I have only found epoll_pwait(4, error: couldn't open Git repository: git rev-parse failed: Unknown option: -C, I can show you the full output of strace if needed.

Make sure that you run strace with the -f option, in which case you should see an execve line something like

18575 execve("/usr/bin/git", ["/usr/bin/git", "-C", ".", "rev-parse", "--git-dir"], 0xc0000d8280 /* 73 vars */ <unfinished ...>

If I run that command in a non-bare repository directory, it succeeds like this:

$ /usr/bin/git -C . rev-parse --git-dir
.git

If I run that command in a bare repository directory, it succeeds like this:

$ /usr/bin/git -C . rev-parse --git-dir
.

Does the same command appear in the strace output for you? If so, what happens when you run it?

It's probably worth trying a more modern version of git. The version that you are using is from 2013. The current version is 2.32. But it would still be helpful if you would help diagnose this problem; maybe it's not version related and/or maybe it would be easy to get it working with older versions of git.

mhagger commented 3 years ago

Please reopen this issue if you gather more information.