gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

Amend commits is not working correctly

Open matthewhardern opened this issue 8 months ago • 11 comments

Version

0.14.16

Operating System

macOS

Distribution Method

dmg (Mac OS - Apple Silicon)

Describe the issue

When trying to amend commit by dragging file onto a previous commit, the history updates, but nothing happens in UI and I get no push option or message to confirm it has worked. It used to work perfectly, a recent update has broken it.

How to reproduce (Optional)

No response

Expected behavior (Optional)

No response

Relevant log output (Optional)


matthewhardern avatar Apr 10 '25 07:04 matthewhardern

Hey Matthew - I am sorry about this regression, this was probably me. Just to clarify, do you mean amending of an uncommitted file or moving a file between commits?

krlvi avatar Apr 10 '25 09:04 krlvi

Amend is not working for me either: It is dragging uncommitted changes in the same row (stack?) down to the commit. But it is kind of worse than not working, because it sometimes does the amend and doesn’t display the result and sometimes it really doesn’t do the amend. I am currently restarting GB to see if it worked or not.

rhizoome avatar Apr 11 '25 08:04 rhizoome

@matthewhardern @rhizoome I am trying to reproduce this issue... Do you know if the change that you are trying to amend is dependent (locked) on another commit that comes after it? Added a screenshot to illustrate this.

Image

This is the only condition where I was able to reproduce this. For example in a commit B one introduces a paragraph or a function and then you have a modification to that same section. If you try to amend that modification to an earlier commit, currently the application does nothing (which is a bug).

What should happen in this scenario is that the app should flag the following commit as "conflicted" so that one can edit that and resolve any merge conflicts.

I intend to fix this, but please let me know if you have a different scenario under which this happens

krlvi avatar Apr 11 '25 09:04 krlvi

It is locked, but I drag it on the an available (later) commit, where it can be applied. Since it actually gets applied, I just have to restart gitbutler to see the change.

Image

It is locked to the oldest commit, but I would drag it on the lastest.

rhizoome avatar Apr 11 '25 09:04 rhizoome

One could in theory check the application logs (https://docs.gitbutler.com/development/debugging#logs) for an entry like this

2025-04-11T09:42:55.774552Z ERROR amend_virtual_branch: crates/gitbutler-tauri/src/virtual_branches.rs:373: error=Error(Failed to amend with commit engine. Rejected specs: [(CherryPickMergeConflict, DiffSpec { previous_path: None, path: "README.md", hunk_headers: [] })]

It appears that this error is not propagated in the UI

krlvi avatar Apr 11 '25 09:04 krlvi

Here is the log:

https://gist.github.com/rhizoome/767b0a63290b98227c5a74073c5bbc57

rhizoome avatar Apr 11 '25 09:04 rhizoome

Since it actually gets applied, I just have to restart gitbutler to see the change.

this seems like a related, but also different issue with the reactivity. It should also be possible to reload the app with Cmd+R (or Ctrl+R)

krlvi avatar Apr 11 '25 09:04 krlvi

Since it actually gets applied, I just have to restart gitbutler to see the change.

this seems like a related, but also different issue with the reactivity. It should also be possible to reload the app with Cmd+R (or Ctrl+R)

You are right. I cannot apply the change in the screenshot. I always get:

2025-04-11T09:50:31.127056Z ERROR amend_virtual_branch: crates/gitbutler-tauri/src/virtual_branches.rs:373: error=Error(Failed to amend with commit engine. Rejected specs: [(NoEffectiveChanges, DiffSpec { previous_path: None, path: "testing/gitbutler/APKBUILD", hunk_headers: [] })]) project_id=32a8443d-fc99-4e79-9f28-fc58202580bc stack_id=6051e42d-e888-4cd6-b52e-371f60e89d98 commit_id="ac2ae99c83b0eedfac48ab3044a9a06892109485" worktree_changes=[DiffSpec { previous_path_bytes: None, path_bytes: "testing/gitbutler/APKBUILD", hunk_headers: [] }]

But I can commit and sqush it, which means that it should be possible do directly amend it.

rhizoome avatar Apr 11 '25 09:04 rhizoome

I just commited and squashed the change to make sure I don't say something untrue and then I of course wanted to revert that change. And I was able to amend the revert (removing the line again) without error. But it didn't update the view and after Ctrl-R I got the correct view.

I can send you a copy of my repository, it is public open source project. (I am going to lunch now)

rhizoome avatar Apr 11 '25 09:04 rhizoome

I think this is a deficiency in the way the amend is currently implemented - I think a solution here is to just reimplement it

krlvi avatar Apr 11 '25 09:04 krlvi

Same on Windows: https://youtu.be/P7klTm-_tlI

I can move hunk to empty/existing commit, but I can't ammend (squash) commit from existing commit to another commit or I can't move hunks between commits...

JoyHak avatar Apr 14 '25 07:04 JoyHak