Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git rebase --edit-todo should not empty the file #739

Open
forivall opened this issue Sep 13, 2022 · 6 comments · May be fixed by #873
Open

git rebase --edit-todo should not empty the file #739

forivall opened this issue Sep 13, 2022 · 6 comments · May be fixed by #873
Assignees

Comments

@forivall
Copy link

I used git rebase --edit-todo to look at how many commits were left in my rebase, but when i didnt change the file, interactive-rebase-tool cleared the file to abort, and then the rebasing ended, and I had to continue the rebase with a cherry-pick of the remaining commits.

@MitMaro MitMaro added the investigate Requires investigation label Sep 13, 2022
@MitMaro
Copy link
Owner

MitMaro commented Sep 27, 2022

TIL! I didn't know about the --edit-todo flag! Very useful.

I've confirmed what you experienced, and although the tool is "working as expected", I can see how the wording around "abort" is confusing when using it to edit the rebase file after the start of the rebase. Git uses an empty rebase file to signal that the rebase should "abort", which does not make sense in the context of editing the todo file for an in progress rebase.

I fully agree that this behaviour is confusing and unexpected when using the --edit-todo flag.

I want to check to see if there is a way to detect the --edit-todo flag, and in those cases, have abort just exit the tool cleanly, without modifying the todo file. If not, I can add an "exit without writing changes option", or I will at least improve the documentation to further explain this situation.

For now, if you use --edit-todo, you can use the "write" command to continue the rebase, but it will write changes.

@MitMaro MitMaro added enhancement and removed investigate Requires investigation labels Sep 27, 2022
@MitMaro
Copy link
Owner

MitMaro commented Sep 27, 2022

I did some digging this evening, and sadly, there isn't any way to determine if git --edit-todo was run, so the only option left if to add "Quit without writing file" feature.

Ideally, this would use the Q keybinding; however, I want to retain backwards compatibility. So, I will need to assign it a different binding.

@forivall
Copy link
Author

Sounds good! Thank you so much for looking into it.

IIRC, I used the q keybinding, and it was my first time using --edit-todo, so i didn't anticipate that it would halt the rebase completely 😭


Actually, I did a bit of digging, and while the editor isnt passed any special environment variables or arguments, I did find a difference between the initial rebase --interactive and --edit-todo:

Check the contents of $(git rev-parse --git-dir)/rebase-merge. In the initial git rebase --interactive, there's

git-rebase-todo  git-rebase-todo.backup  head-name  interactive
no-reschedule-failed-exec  onto  orig-head

but in --edit, there's

amend  author-script  done  end  git-rebase-todo  git-rebase-todo.backup
head-name  interactive  message  msgnum  no-reschedule-failed-exec
onto  orig-head  patch  stopped-sha

Overall, I think using the existing keybindings are good, but when those interactive rebase state files are present, just show some warnings.

@forivall
Copy link
Author

(Honestly, at this point, I'm open to creating a PR myself this weekend for good ol' hacktoberfest, and to finally get my hands dirty with rust)

@MitMaro
Copy link
Owner

MitMaro commented Sep 28, 2022

Thanks for digging in!

Absolutely support any effort to dig into this for hacktoberfest. I will also be happy to provide assistance. :)

but when those interactive rebase state files are present, just show some warnings.

I think I would avoid writing the file when using abort (q) in that case, since it's unexpected and leaves git in a odd state.

@forivall
Copy link
Author

forivall commented Dec 27, 2022

finally starting work on it. baby's first rust code forivall/git-interactive-rebase-tool@forivall/vscode-settings...forivall:git-interactive-rebase-tool:forivall/edit-and-revise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants