gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

broken worktrees

Open mfattakhov opened this issue 1 year ago • 10 comments

Version

0.15.15

Operating System

macOS

Distribution Method

dmg (Mac OS - Apple Silicon)

Describe the issue

When using worktrees and having a branch, that is identical to a vritual branch gitbutler instead of adding a commit to this virtual branch does this:

  1. renames your vritual branch to a name that is used in a separate worktree
  2. adds a dependent branch that is called as the original one did
  3. put a commit to this new top branch
Image

worked well until ~0.15.13, certainly worked well 3 weeks ago

How to reproduce (Optional)

  1. have a separate workdtree
  2. use this alias in git cli
review = "!f() { \\\n  git fetch origin && \\\n  git checkout -B \"$1-review\" origin/\"$1\" && \\\n  git branch --set-upstream-to=origin/\"$1\" \"$1-review\" && \\\n  git reset --hard origin/\"$1\"; \\\n}; f"
  1. create a pr from your branch in gitbutler UI
  2. in a worktree run git review branch_name
  3. try to make a commit to your branch via gitbutler UI

Expected behavior (Optional)

No response

Relevant log output (Optional)


mfattakhov avatar Aug 28 '25 10:08 mfattakhov

Thanks a lot for reporting!

Generally, worktrees aren't supported and it should refuse to add repositories that have worktrees configured. However, this check only runs once and it's certainly possible to add a worktree after the parent project to GitButler, yet it shouldn't be possible to add that worktree to GitButler.

What I assume is happening here that the worktree is added after the parent project was added to GitButler, then a worktree is created, and the worktree branch is then brought into the GitButler workspace. This is definitely an interesting usecase, and one we definitely should support, along with worktrees proper.

Could it be that the issues started when we switched to the new workspace backend? You can still compare by reverting to the old one using the global settings, Experimental -> New workspace backend.

Does it work with the old backend?

Besides that, I probably didn't perfectly follow the reproduction, if you find the time, a video would definitely help my understanding.

Thanks again.

Byron avatar Aug 28 '25 13:08 Byron

Could it be that the issues started when we switched to the new workspace backend?

I guess no, it totally worked well after you handled the issue with squash-merged stacks for me, at that time I was already using the new backend

Here is how to reproduce:

https://github.com/user-attachments/assets/316260b7-f3f9-4e6a-ad0e-1bcf73b7ae77

mfattakhov avatar Aug 28 '25 14:08 mfattakhov

Wow, thanks so much for the video, that changes everything :).

This definitely is related to the new workspace engine, which might now surface due to a fix in another place. Here it would be interesting to see the result after type dot in the UI, as it will show the commit-graph as GitButler sees it. The problem here is the br4-review branch which probably is linked up with the remote. This is why it seems to capture the integrated commit.

Then, the actual tip of the stack, br4 is receiving a new commit, so it's advanced, and it's local, and because it never had the remote officially setup, it seems like a dependent branch.

This is expected behaviour for now, and can be resolved by deleting the workspace and/or the review branch.

However, it's not desirable behaviour, and in future GitButler will setup a proper remote configuration for each branch after pushing, which will probably keep the stack intact.

Byron avatar Aug 28 '25 16:08 Byron

When I press d o t on a keyboard nothing happens, is it a debug feature?

mfattakhov avatar Aug 29 '25 11:08 mfattakhov

It is - if it's typed into a non-editable portion of the interface, it would typically show an error if no dot program is installed via graphviz - not seeing anything probably means it didn't register - something that is unusual.

Byron avatar Aug 29 '25 12:08 Byron

Did you manage to reproduce the behavior? I am using stable release, no error occurs, mouse pointer disappears and that's it

mfattakhov avatar Aug 29 '25 14:08 mfattakhov

I don't think I follow the note about the mouse pointer that disappears.

Besides that, did you try to delete extra branch? Another issue here is that the UI doesn't automatically update when branches change, so it seems to update only once the new commit is created even though it's already in the new state where br4-review shows up.

Like mentioned before, it could be deleted, or its remove configuration can be removed. Does that work?

Byron avatar Aug 29 '25 17:08 Byron

Yes, deleting the branch helps, but it is not a desired behavior, extra hops are needed. It works well via separate repo, not a worktree so I am satisfied.

Here is the mouse pointer disappearing:

https://github.com/user-attachments/assets/99f236c5-46cf-4647-9f32-c88d8044709e

It disappears right when I press the last letter of dot, the t. It reappears easily with any movement. Don't think that this behavior requires investigation, might be a waste of time.

mfattakhov avatar Aug 29 '25 18:08 mfattakhov

Right, I keep forgetting that this only works if dot is available in the PATH, which is usually only the case when GB is launched from a terminal. Then the mouse-pointer disappears only while the browser opens.

Byron avatar Aug 30 '25 08:08 Byron

Thanks again for the detailed repro and videos. We now have a dedicated tracking issue for worktree support in #10677, including the case where a branch advances from another worktree and GitButler needs to bring that state back into the workspace correctly.

I’m closing this as a duplicate so the work and discussion stay in one place. Please follow #10677 for updates.

krlvi avatar Jul 19 '26 19:07 krlvi