Description
I'm using git worktree feature (https://git-scm.com/docs/git-worktree) in my repository to work with multiple brances simultaneously.
In this case the solution directory structure looks as follows:
root
- .git folder
- solution.sln (master branch sln)
- other main branch files and folder
- worktree1 root folder (branch1)
- solution.sln (branch1 brunch sln)
- other branch1 files and folder
- worktree2 root folder (branch2)
- solution.sln (branch2 brunch sln)
- other branch2 files and folder
....
When I working with master brunch, all Git toolbar commands works fine.
But when I working with the solution from the worktree folder (e.g. worktree1\solution.sln), the GitToolbar commands works for master root folder, not for the worktree root. So, I can't see my worktree changes in commit dialog and so on.
As I can see, for now the GitToolbar looks for .git folder to deside in what folder to run TortoiseGit's command. But worktree folders do not have .git subfolder and thus we have incorrect behaviour here.
Iooks like that the better solution will be to ask git itself for correct root folder. "git rev-parse --show-toplevel" command will return the following depending of the current folder
- "fatal: not a git repository (or any of the parent directories): .git" - if we not inside git repo at all
- full path of the root folder of the "ordinal" git repo (root on my structure) when called from inside the ordinal repo
- full path to the root of the submodule folder (where the .git file of the submodule is located) if called from inside the git submodule path.
- full path to the root of the worktree folder (where the .git file of the worktree is located) if called from inside the worktree
The alternative way may be to check not only for ".git" directory, but also for the ".git" file, because for the submodules and worktrees git use exactly the .git file in the root folder