Open abathur opened 5 years ago
Another (more flexible, but maybe overkill?) option would just be, whether through accepting paths last with a flag to change the meaning, or a git-style --
path separator, support passing an explicit list of paths directly to the git repositories themselves, and let the user do whatever makes sense in their case.
If I understand you correctly, you mean support for work trees that are different than the location of the .git
dir? I think they're called "detached working dirs" or something. Like this:
# Create a separate "checkout" in ~/Temp/mgs/
$ git --git-dir ~/Projects/fboender/multi-git-status/.git --work-tree ~/Temp/mgs reset --hard
I suspect that this is what yadm does under the hood, much like other dotfile managers.
Multi-git-status needs to know both the working dir and the .git
dir locations. Otherwise, it cannot give meaningful information on much of the state of a repository. However, there is no link between the two (unless the .git
dir is in the working dir), and no way for multi-git-status to figure out their locations.
For example, I can use something like this to match all of the git repositories mgitstatus finds, plus the yadm repo I mentioned: find -L . -maxdepth 3 -type d -name "*.git"
This is already what mgitstatus does at the moment. See line 128. But mgitstatus needs both the .git
dir and the working tree.
I currently don't see a very user-friendly way on the commandline for the user to provide a mapping between where the .git
files are located and where the working tree is for multiple repositories. Unless I add something like a configuration / mapping file. Perhaps something like this:
# <work tree> [.git path]
/home/fboender/Temp/mgs /home/fboender/Projects/fboender/multi-git-status/.git
/home/fboender/foo /home/fboender/Projects/fboender/foo/.git
That's a bit of a departure from the way mgitstatus works now. I'm not sure it's worth it to support such a (I assume) fringe use-case.
Good point. I agree that it's probably an edge-case that doesn't justify significantly complicating anything.
I'll try to find some time to think on/poke at the source.
Had a little time to pick at implementing this directly in command syntax. The basic functionality is pretty simple, but finding logical/syntactical space for it is a little trickier...
Here are the main ways I've thought about it:
--
arg to separate them.
--
is already a git syntax idiom, and this does use it in a similar-but-not-identical way.Curious how these strike you.
It would be nice to be able to point mgitstatus at nonstandard git repos.
My personal use-case is the yadm dotfile manager https://github.com/TheLocehiliosan/yadm, which is uses a distinct path. Typically we'd just interact with that repo via
yadm <git-sub-command>...
, but we can also do something like GIT_DIR=~/.yadm/git.repo git status to run plain git commands against it.I'm not sure what's best in terms of syntax/implementation (I can imagine a few different ways...) but a fairly simple idea is a flag to specify one
-name
to thefind
command. For example, I can use something like this to match all of the git repositories mgitstatus finds, plus the yadm repo I mentioned:find -L . -maxdepth 3 -type d -name "*.git"
(I had to adjust the maxdepth up 1, though, since that's matching deeper in the tree).