godot-git-plugin icon indicating copy to clipboard operation
godot-git-plugin copied to clipboard

Project sometimes crashes when staging deleted or renamed files.

Open daveTheOldCoder opened this issue 2 years ago • 4 comments

Godot v4.0.4.stable.official [fc0b241c9] / Plugin v.3.0.0

This problem has occurred a couple of times. I deleted a file from inside the Godot Editor. Then the file deletion is listed in Commit/Unstaged Changes in the Inspector. When I attempt to stage the change, the project closes, and cannot be re-opened from the Godot project manager.

After that happens, the only solution I found is to restore the project from a working backup. Maybe the project could be fixed using Git commands outside of Godot, but I couldn't find a way to do that. (I'm a Git novice; a Git expert might have ideas.)

A workaround is instead of staging a file deletion using the plugin, use this Git command outside of the Godot editor: git rm <file>

Then the deleted file will move from Commit/Unstaged Changes to Commit/Staged Changes, and the change can be committed.

This problem does not always happen when deleting files. I tried to create a minimal reproduction project, but was not successful.

daveTheOldCoder avatar Sep 11 '23 18:09 daveTheOldCoder

The problem reoccurred, using plugin v3.0.1 with Godot 4.2-dev5.

This time, I successfully repaired the broken project. Details follow.

After renaming two files (simple.gd -> simple_example.gd, detailed.gd -> detailed_example.gd), the files simple.gd and detailed.gd were listed under Unstaged Changes, with "(Deleted)" next to them. The project crashed when I attempted to stage those changes. The project could not be opened with the project manager.

Here's the git status output: $ git status On branch master Changes to be committed: (use "git restore --staged ..." to unstage) renamed: detailed.gd -> detailed_example.gd modified: main.tscn modified: project.godot renamed: simple.gd -> simple_example.gd

(The changed files main.tscn and project.godot are probably not related to this problem.)

I unstaged the two problem files: $ git restore --staged detailed.gd $ git restore --staged simple.gd

Then I was able to open the project with the project manager.

Inside the Godot editor, the two files were listed under Unstaged Changes. I clicked the X next to each of them to discard the changes. Then I closed Godot, and removed the files from git tracking, and then deleted them: $ git rm --cached simple.gd rm 'simple.gd' $ git rm --cached detailed.gd rm 'detailed.gd' $ rm simple.gd $ rm detailed.gd

After that, the project was back to normal.

When the project was broken, I tried opening it from the command line: $ ~/bin_godot4.2/Godot_v4.2-dev5_linux.x86_64 -e --path ./

That failed to open the project, and the only abnormal output was:

terminate called after throwing an instance of 'std::out_of_range'
  what():  _Map_base::at
Aborted (core dumped)

I saved a copy of the project folder when it was broken. If there's anything you want me to look at or try, let me know.

daveTheOldCoder avatar Sep 23 '23 08:09 daveTheOldCoder

While trying to move a few files around and synchronously committing the changes, I experience the same issue as described above. I am on windows, using the unreleased version with the loading error fix.

Marenz avatar Oct 13 '23 00:10 Marenz

I am having this issue with the unreleased version as well. 4.2 beta 3. WORKAROUND TO STOP CRASHING: Commit your changes from Github Desktop, no command line needed. You don't even have to push, just committing is enough to stop the crash.

Adding to ruguysgoingtrickortreating's comment, I've found that a workaround is simply to do git staging and committing outside of the Godot editor when deleted/renamed/moved files or folders are involved. It can be done using git from the command line or with one of the many git GUI's. It doesn't seem to matter whether the project is open in the Godot editor, or whether the editor has already crashed.

daveTheOldCoder avatar Nov 06 '23 17:11 daveTheOldCoder