Theia: Git fails to register deletion of new staged files

Created on 11 May 2020  路  7Comments  路  Source: eclipse-theia/theia

Bug Description

I'm going to do my best to explain this confusing bug.

Say you are in a git repository.

If you add a file called file.txt, head to the git tab, and then stage it, it switches to the staged section as expected.

However, if you delete this file, it disappears from the staged section - again, as expected.

But once you do commit, you will see that one pending change which was not visible before is now showing itself - the deletion of file.txt!

Steps to Reproduce

  1. Init a git repo
  2. Create a file
  3. Stage the addition of this file through the Git GUI
  4. Head back to files and delete the new file
  5. Return to git tab and commit
  6. See bug


Additional Information

  • Operating System: ubuntu focal
  • Theia Version: gitpod
bug git help wanted

Most helpful comment

@vince-fugnitto In Gitpod @theia/git is used.

Yes I know, just wanted to confirm if it also an issue in vscode and with the builtins.
My reasoning was if it is a bug only with @theia/git and that it is a small corner case that the bug is not a big priority.

All 7 comments

@RDIL do you mind confirming the same behavior in vscode?
Eventually support for @theia/git will be dropped in favor of vscode-builtin-git and vscode-builtin-git-ui.

@vince-fugnitto In Gitpod @theia/git is used.

@vince-fugnitto In Gitpod @theia/git is used.

Yes I know, just wanted to confirm if it also an issue in vscode and with the builtins.
My reasoning was if it is a bug only with @theia/git and that it is a small corner case that the bug is not a big priority.

for me at step 5 I see this:
image
but it commits the addition of the file which is what I would expect.
and in the git tab, I still have the deletion of the file as a change, yet to be staged/commited.

Alright so this is only in Theia

However, if you delete this file, it disappears from the staged section - again, as expected.

No, that is not as expected. Deleting the file deletes it in the working tree. It does not affect the index. Seeing the deletion after one has committed is correct because the file was added in the commit.

The error is in fact that the file does not show at all after the deletion and before the commit. It should show as added in the staged changes and deleted in the unstaged changes. The problem is caused by these lines:

https://github.com/theia-ide/dugite-extra/blob/815ff1886b3e1f159d670b9c8ed619e4addb2e57/src/command/status.ts#L109-L117

The comment is incorrect. Those lines just need to be removed. One will then see the file added in the staged changes and deleted in the unstaged changes as expected (i.e. as vscode does and as git-gui does).

Was this page helpful?
0 / 5 - 0 ratings