Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git worktree support #21

Open
snechaev opened this issue Dec 21, 2019 · 2 comments
Open

Git worktree support #21

snechaev opened this issue Dec 21, 2019 · 2 comments

Comments

@snechaev
Copy link

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

@MattDavies
Copy link
Member

Hey @snechaev agree the better solution here is rev-parse. Great debugging. Feel free to submit a PR else I'll look at this when I can.

snechaev pushed a commit to snechaev/TortoiseGitToolbar that referenced this issue Dec 23, 2019
…oot instead of searching for .git folder (old approach still exists as fallback in case when git-based solution fails)
@snechaev
Copy link
Author

Just added PR #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants