vscode-gitlens icon indicating copy to clipboard operation
vscode-gitlens copied to clipboard

Unable to undo commit after rebase

Open RaptorX opened this issue 1 year ago • 12 comments

Type: Bug

• Rebase a few commits from one branch to another. • Try to undo the last commit from the rebased branch

Expected

We should be able to undo the last commit

Result

We get an error stating that the last commit is no longer the most recent one even though that is incorrect.

image

Notes

image

The last four commits were rebased and are now on the devel branch. GitLense seems to be pointing to where HEAD is atm and still thinks that that is the last commit even though those 4 commits "dont exist" anymore as seen by git graph.

image

Doing the process using the terminal works as intended. But we can no longer use the GUI to undo commits.

Extension version: 14.3.0 VS Code version: Code 1.83.0 (e7e037083ff4455cf320e344325dacb480062c3c, 2023-10-03T16:12:16.321Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 x 3198)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.88GB (20.53GB free)
Process Argv --crash-reporter-id 3e042e59-cb22-4371-968a-6f3e35abe666
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
3biah626:30602489
f6dab269:30613381
showlangstatbar:30737416
0bi6i642:30841073
a2ce3375:30757347
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30845448

RaptorX avatar Oct 09 '23 15:10 RaptorX

I'm not able to reproduce this issue at the moment - can you check if my steps sound correct @RaptorX ? And if possible, could you confirm that the issue is still occurring on the latest Pre-release version of GitLens?

To attempt a minimal repro, I did the following:

  1. Initialized a new repo with a main branch and an initial commit.
  2. Made a branch test from main.
  3. Made some changes on main and committed.
  4. Made some changes on test and committed.
  5. Rebased test onto main (I used the context menu command Rebase Current Branch onto Branch... in the Commit Graph - let me know if you rebased in a different way).
  6. Went to the last commit in the Commits View and clicked the Undo icon.
  7. The commit was undone, as expected.

axosoft-ramint avatar Dec 12 '23 20:12 axosoft-ramint

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

github-actions[bot] avatar Dec 20 '23 05:12 github-actions[bot]

I just got the same issue on a different repository. Im trying to replicate the issue reliably but I am unable to as well

This only happens from the GUI. Performing git reset HEAD~ on the terminal works fine.

image

RaptorX avatar Dec 21 '23 20:12 RaptorX

I havent been able to reproduce exactly but here is an update:

This issue is not happening only after a rebase, I havent been able to determine what causes it. Quick thing, the repositories I work with are in a DropBox folder. Not sure if that would interfere with the file dates when syncing and maybe causing an issue with GitLens.

Im working on a different project and I have never done a rebase. I am also getting the issue of not being able to reset the last commit from the GUI.

Gitlens clearly thinks that is the latest commit: image

It shows as the latest commit in both interfaces: image

I still get this error: image

But using the terminal and typing git reset HEAD~ works without issues.

After saving the commit, we should clearly have the newest commit. But if I try to reset from the GUI I would get the same error.

Somehow GitLens is loosing track of the latest commit at some point. Reloading VSCode does not help.

Once I get this error I cant reset commits from the GUI again, and I havent found a way to fix it except from nuking the repository and starting over.

RaptorX avatar Jan 07 '24 15:01 RaptorX

Though I still can't reproduce your issue, I can help investigate a bit further.

What happens in those cases if you use the Git: Undo Last Commit command from the Command Palette? (You can access the command palette using CTRL/CMD + SHIFT + P).

image

Note: This command is owned by VSCode's SCM extension, not GitLens, but testing it would help determine the scope of the issue.

axosoft-ramint avatar Jan 09 '24 17:01 axosoft-ramint

Though I still can't reproduce your issue, I can help investigate a bit further.

What happens in those cases if you use the Git: Undo Last Commit command from the Command Palette? (You can access the command palette using CTRL/CMD + SHIFT + P).

[image]

Note: This command is owned by VSCode's SCM extension, not GitLens, but testing it would help determine the scope of the issue.

Steps and Results

  • created a test commit
  • tried reverting with GitLens -- Got an error
  • opened the command palette
  • used Git: Undo Last Commit -- Worked totally fine

RaptorX avatar Jan 09 '24 18:01 RaptorX

Thanks - and where in the GitLens GUI are you trying to undo the commit? Are you using the context menu on the latest commit from within the commit graph? Or from one of GitLens' views (Commits View, Branches View, Repositories View, etc.)?

And just in case it's relevant, where are you committing from? Within VS Code's SCM or terminal etc.?

axosoft-ramint avatar Jan 09 '24 18:01 axosoft-ramint

This happens from VS Code SCM interface:

image

RaptorX avatar Jan 11 '24 19:01 RaptorX

Hi there.

I experience the same issue.

  • Clicking on Undo commit always ends on "Commit cannot be undone, because it is no longer the most recent commit."
  • Using Git: Undo Last Commit in command palette works

bastienho avatar Mar 18 '24 09:03 bastienho

Happens only on forks. Works fine on own repos

To reproduce:

  • fork and clone any public repo
  • edit, commit and push to remote
  • try undoing (as RaptorX described above)
  • get the message

GitLens v14.9.0 git v2.43.2

efojs avatar Mar 24 '24 01:03 efojs

Happens only on forks. Works fine on own repos

To reproduce:

  • fork and clone any public repo
  • edit, commit and push to remote
  • try undoing (as RaptorX described above)
  • get the message

GitLens v14.9.0 git v2.43.2

Interesting that you mention that.

My cases are not forks per se, but they are github repositories that I have cloned locally.

My test on clean local repositories were not failing, but my test on most repositories with an upstream setup did produce the bug above.

So I might lean towards agreeing that the bug might be related to forked or cloned online repositories.

Ill test a bit more and see.

RaptorX avatar Mar 25 '24 13:03 RaptorX

This issue might be possibly related to #3133, as it happens in the same type of repos that the other bug happens as well.

RaptorX avatar Apr 18 '24 17:04 RaptorX