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

A locked hunk moves all other changes in the same file to the default branch #4148

Closed
daniilS opened this issue Jun 21, 2024 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@daniilS
Copy link
Contributor

daniilS commented Jun 21, 2024

Version

0.5.552

Operating System

Windows

Distribution Method

msi (Windows)

Describe the issue

When a new change is locked to a vbranch, it causes all previous changes in the same file to move to whatever the current default branch is.

How to reproduce

  1. Create a file big enough for two changes to appear as different hunks.
example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

  1. Create three vbranches. Make a change somewhere in the file, and commit it to vbranch 1:
Example screenshot:

image

  1. Make a separate change in vbranch 2, far enough from the previous change to not lock. Set vbranch 3 as the default branch.
Example screenshot:

image

  1. Now, make a change close to the committed change in vbranch 1, so that it will lock to vbranch 1.

    Notice that the existing change unexpectedly moves from vbranch 2 to vbranch 3 (the default branch). If you now change the default branch, the not-locked change will immediately move there.
Example screenshot:

image

Expected behavior

A hunk locking should not affect the ownership of the other hunks in the same file. Changing the default branch should also not affect the ownership of existing hunks.

Relevant log output

No response

@daniilS daniilS added the bug Something isn't working label Jun 21, 2024
@Byron
Copy link
Collaborator

Byron commented Jun 21, 2024

Thanks a lot for reporting, and for making the issue so straighforward to reproduce. When using Version 0.5.552 (20240621.032126), I could definitely reproduce the 'unlocked hunk is pulled to another vbranch', even though for me it was pulled to vbranch 1 together with the hunk that is close to the locked hunk (that was committed there).

Screenshot 2024-06-21 at 22 43 14

The default branch (branch 3) didn't seem to contribute here. However, it might be me having not followed the reproduction steps precisely enough, or it's some other factor. What matters is that the unlocked unlocked hunk should probably not have been pulled over as well, at least it's surprising.

@daniilS
Copy link
Contributor Author

daniilS commented Jun 22, 2024

@Byron in your screenshot, are the two changed lines the only changes that you made after the committed change?

If yes, then those form one hunk (because their context lines overlap), which is why they both get moved to the locked branch (until hunk splitting is supported). If you make the non-locking change far enough away to be in a separate hunk, then the non-locking change will get moved to the default branch, which is what my bug report is about.

If no, then can you show the two hunks corresponding to the two changes that you made in step 3 and 4 so I can try figure out what's different?

@Byron
Copy link
Collaborator

Byron commented Jun 22, 2024

That's interesting - now that I tried again, I have a different result and one that I'd consider correct. However, I also had all the vbranches already with the default set to branch 3, maybe that affected it as well.

Additionally, maybe it's important to use the proposed file (I used an existing README), and to add changes exactly where you specify (i.e. line 1, 5, 10), for it to work reliably.

@mtsgrd
Copy link
Contributor

mtsgrd commented Jun 24, 2024

I can reproduce this, take a quick look and see if I can find out what's going on.

mtsgrd added a commit that referenced this issue Jun 25, 2024
- also removes useless if branching
mtsgrd added a commit that referenced this issue Jun 25, 2024
mtsgrd added a commit that referenced this issue Jun 25, 2024
mtsgrd added a commit that referenced this issue Jun 25, 2024
@mtsgrd mtsgrd closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants