seeraven / gitcache

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

Check Setup on Each Execution of gitcache #21

Closed seeraven closed 4 days ago

seeraven commented 1 year ago

gitcache is a wrapper for git, so it needs to intercept the command line calls of git (resp. git.exe on windows). But to work with git, gitcache itself also has to call the real git command.

To ensure gitcache is called as git we can either

And to ensure it is called instead of the real git it must be placed in a directory referenced by the PATH variable before the directory containing the real git command. Actually, the real git command can also be in a directory not referenced by the PATH variable as long as the realgit config setting of gitcache is correct.

Currently, the detection of the real git command works by doing something similar to shutil.which but ignoring symlinks. This can lead to recursive calls of itself if the user did not create a symlink but a copy or rename operation.

So the initial detection of the real git command must be changed. Here, the question is how to identify an executable of git as a real git command. We can't use an option that is handled by git as any wrapper like ourself will simply forward it, but we can add an option to identify whether the candidate is actually gitcache by adding a new git option --identify.