seeraven / gitcache

Local cache for git repositories to speed up working with large repositories and multiple clones.
BSD 3-Clause "New" or "Revised" License
33 stars 6 forks source link

Error fetching repos that don't have a master branch #22

Open afabian opened 11 months ago

afabian commented 11 months ago

We have a repository with various branches, but none called "master". It looks like that branch name is getting added and causing checkouts to fail:

2023-11-09 09:59:08 Command 'C:\Users\afabian\AppData\Local\Programs\Git\cmd\git.exe -c lfs.storage=c:\gitcache\cache\mirrors\REPO_PATH\lfs lfs fetch origin master' failed with return code 2. Starting retry 2 of 3. Invalid ref argument: [master]

I think the expected behavior is to check out the ref specified by the parent repository. Come to think of it, "master" would be wrong even if it did exist.

Edit: just realized I said "checkouts" but the actual command was "submodule update --init --recursive"

afabian commented 11 months ago

Awesome tool, by the way!

seeraven commented 11 months ago

The default branch resp. ref should be determined by calling git symbolic-ref --short HEAD or by using git show-ref <ref> if used within the git checkout <ref> context. So if you are using a recent version of gitcache, there is no hard-coded "master" in it. Can you check the output of the git symbolic-ref --short HEAD command? I would like to recreate an example repo simulating your use case. I assume you have a repository with one or more submodules (which in turn have again submodules) and at least some of them are using LFS, right?