find git-dir directly and look up work-tree#53
Open
abathur wants to merge 1 commit intofboender:masterfrom
Open
find git-dir directly and look up work-tree#53abathur wants to merge 1 commit intofboender:masterfrom
abathur wants to merge 1 commit intofboender:masterfrom
Conversation
This enables mgitstatus to handle repositories with non-standard work
tree locations (such as those used by yadm). It can discover these, or
the user can explicitly list the path to the git-dir.
Two broad strokes to this:
1. Instead of checking every sub-directory for a .git directory in the
standard location, search directly for directories matching "*.git".
- Since *standard* .git directories will be one level deeper in the
tree, this adds 1 to DEPTH.
- Since we're looking for the .git directory itself, I think we can
use -prune to skip searching within those matching directories.
2. Use `git rev-parse --show-toplevel` to look up the work tree. As
far as I can tell, this will report the path of a non-standard
work tree. This will error (and print nothing) on a standard repo.
If that fails to produce output, fall back on the existing guess
that the work tree will be the parent directory of the git-dir.
Most of the diff is from computing this once (as PROJ_DIR) and
replacing instances of `$(dirname "$GIT_DIR")` with it.
Author
|
Aside: If it helps anyone, I have this packaged as a Nix flake for my own use at https://github.com/abathur/multi-git-status/tree/lookup_worktree_flake |
tobixen
added a commit
to tobixen/multi-git-status
that referenced
this pull request
Dec 22, 2025
Add -l/--list FILE option to read repo paths from a file instead of scanning. Add -s/--save-list FILE option to scan and save repo paths to a file. The list file supports comments (lines starting with #) and empty lines. Based on PR fboender#27 by cipherbrain, adapted to work with the find_git_work_tree approach from PR fboender#53. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tobixen
added a commit
to tobixen/multi-git-status
that referenced
this pull request
Dec 22, 2025
Document which pull requests have been integrated into this fork: - PR fboender#62: reftable refs format support - PR fboender#61: make uninstall target - PR fboender#53: improved git-dir detection - PR fboender#51: FHS-compliant man page path - PR fboender#27: list file support Updated usage section with new options (-b, -l, -s, -h). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
rymdbar
pushed a commit
to rymdbar/multi-git-status
that referenced
this pull request
Feb 14, 2026
Pull-request fboender#53 broke `--no-depth`. When searching for GIT_DIR (.git) rather than parent PROJ_DIR (actual repo), the max-depth clearly also needs to be increased.
|
This pull-request needs to also use a higher maxdepth for diff --git a/mgitstatus b/mgitstatus
index 41636bc..b803a78 100755
--- a/mgitstatus
+++ b/mgitstatus
@@ -322,7 +322,7 @@ if [ "$NO_DEPTH" -eq 1 ]; then
# Do not recurse at all. Really, this should have been the '-d 0' option,
# but that's already used for infinite recursion, and we don't want to
# break backwards compatibility.
- FIND_OPTS="$FIND_OPTS -maxdepth 0"
+ FIND_OPTS="$FIND_OPTS -maxdepth 1"
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This enables mgitstatus to handle repositories with non-standard work tree locations (such as those used by yadm) and would close #26. It can discover these within the directory tree, or the user can use positional args to explicitly list the path to the git-dir.
Two broad strokes to this:
Instead of checking every sub-directory for a .git directory in the standard location, search directly for directories matching "*.git".
Since standard .git directories will be one level deeper in the tree, this adds 1 to DEPTH.
Since we're looking for the .git directory itself, I think we can use -prune to skip searching within those matching directories.
Use
git rev-parse --show-toplevelto look up the work tree. As far as I can tell, this will report the path of a non-standard work tree. This will error (and print nothing) on a standard repo. If that fails to produce output, fall back on the existing guess that the work tree will be the parent directory of the git-dir.Most of the diff is from computing this once (as PROJ_DIR) and replacing instances of
$(dirname "$GIT_DIR")with it.