gitbutlerapp / gitbutler

The GitButler version control client, backed by Git, powered by Tauri/Rust/Svelte
https://gitbutler.com
Other
12.66k stars 503 forks source link

Loss of uncommitted data using unapply #3765

Open gullitmiranda opened 4 months ago

gullitmiranda commented 4 months ago

Hello, I recently ran some tests on GitButler and accidentally lost all the uncommitted changes I had made when I clicked on the "unapply" option. I was struggling to move an uncommitted file to a virtual branch, but it wasn't working. These files were in the staging area before configuring GitButler. Now, it seems like I've lost all my work.

If the "unapply" option is meant to discard changes, shouldn't there be a confirmation prompt before doing so?

krlvi commented 4 months ago

Hey! This is definitely not something that should happen. Just so that I understand better what happened - after unapply, are you able to see your unapplied branch on the sidebar, but without the most recent changes?

In case there's bug that create such a scenario, it should still be possible to recover changes - check out this guide: https://docs.gitbutler.com/troubleshooting/recovering-stuff This is not a super ergonomic recovery process (and we are working on a better interface, which should land this week), but the diffs should be there.

If it would be helpful I can walk you through this on Discord / whatasapp so that you get your changes back. Then afterwords, if possible, I'd love to take a look at the application logs and try to see if I can recreate this.

gullitmiranda commented 4 months ago

Sorry for the delay @krlvi .

I ended up finding the documentation on recovery after creating the issue, but I didn't have time to test recovery from wd

just fyi, what I tested and it didn't work

  1. Recovery from lost commits (reflog)
  2. Recover using git for-each-ref | grep gitbutler, but it did not have the information discarded from the stage.

Having said that, I've already taken a preliminary look at wd (https://docs.gitbutler.com/troubleshooting/recovering-stuff#recovering-a-working-directory-state), it seems to me that at least some of the changes are there.

I'll try to look into this sometime this week, as this specific loss is more a matter of convenience, as it concerns my dotfiles. So it's not something crucial that I can't lose.

asd20752 commented 3 days ago

Also run into this issue today, 4 Virtual branches. Un-applied one to virtual branch to check something, then applied back. Most of the changes that had been done were removed, but not all. Coding was done with Visual Studio GitButler version 0.12.27 The file that lost the most data were common between all Virtual branches with no overlapping changes. Tried undo functionality in GitButler. There were no recollection of the changes ever having been made in the history, and undoing to before "unapply" did not recover the data.

The lost data did not take long to recode (no recovery needed).

Byron commented 3 days ago

I am so sorry to hear that :/!

There have been fixes for a function (create_wd_tree()) that might miss local changes under some circumstances (and I introduced this bug even 😭), that could be responsible for this issue . The problem has since been fixed, and is available in the latest nightly. Maybe you can give that a try in the hopes that nothing like it will re-occur then.

Also CC @krlvi.

mtsgrd commented 2 days ago

I was able to reproduce this, and it has to do with a flaw in our hunk locking/dependency calculation. Under some circumstances where a hunk should be locked it shown as unlocked, and you can move it between branches. If such a hunk is on the branch that you unapply then currently it will be lost.

Given we have had a few user reports related to this I'll take a look at it right now. Expect an update within a few days.