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

Support Grebase --continue/--edit-todo editor invocation #1139

Merged
merged 2 commits into from
Dec 28, 2018
Merged

Support Grebase --continue/--edit-todo editor invocation #1139

merged 2 commits into from
Dec 28, 2018

Conversation

rbong
Copy link
Contributor

@rbong rbong commented Dec 26, 2018

As discussed in #797

copen was decided as the method of feedback for the user on Grebase --continue because cwindow obfuscates user feedback.

The exact method for --edit-todo discussed was not used. You don't need to copy the file, edit it, and move it back. You just need to edit the file. The only difference between this and invoking --edit-todo via the command line is that the commit hashes are not contracted and expanded. This requires using git rebase--interactive --expand-ids and git rebase--interactive --shorten-ids, which are internal helpers and can't be relied on to remain publicly accessible.

Grebase --edit-todo does not yet support window mods but it easily can. Let me know if you think this is needed now.

I also believe that it would be useful to have --continue and --edit-todo rebase autocompletion. This is another thing that can easily be added if you think it should be part of this PR.

autoload/fugitive.vim Outdated Show resolved Hide resolved
autoload/fugitive.vim Outdated Show resolved Hide resolved
autoload/fugitive.vim Outdated Show resolved Hide resolved
autoload/fugitive.vim Outdated Show resolved Hide resolved
autoload/fugitive.vim Outdated Show resolved Hide resolved
On a rebase instruction that should result in an immediate commit,
the quickfix list will be closed and Gcommit will be called.
@rbong
Copy link
Contributor Author

rbong commented Dec 27, 2018

I've done some more testing and the code that adds informational rebase messages to the quickfix causes the commit window not to open. I'm pushing up a fix momentarily that updates the code which checks that there are no errors in the quickfix list by excluding informational lines.

@tpope
Copy link
Owner

tpope commented Dec 27, 2018

This will result in a "problem with editor false" style error in the quickfix list on --edit-todo, correct? I think the check for it should be moved up to avoid that. Other than that looks good.

@tpope tpope merged commit b66141e into tpope:master Dec 28, 2018
@tpope
Copy link
Owner

tpope commented Dec 28, 2018

I'll deal with that later.

@rbong
Copy link
Contributor Author

rbong commented Dec 29, 2018

edit: whoops, didn't see your latest message. Glad it's in.

It will result in that error in the quickfix list, but the quickfix list will not be opened. However, we can avoid that error by simply changing the editor "true" rather than "false" when "--edit-todo" is passed in. I'm pushing that up now.

I am not entirely sure if this is the approach you were thinking of, but it preserves error checking by running the git rebase --edit-todo command while also keeping the "problem with editor false" error out of the quickfix window in case the user opens it.

Also, I want to make sure you know that the same behaviour will happen on "--continue". The editor error will be in the quickfix window, but the quickfix window will not automatically open if there is a commit message to edit. Causing an error using $GIT_EDITOR is the only way I know of to pause the rebase so we can edit commit messages. I assumed that was okay because %-Gerror:%.%#false was in the list of error formats, but if it's not okay and there's some way to get around actually having this error in the quickfix list let me know.

@tpope
Copy link
Owner

tpope commented Dec 29, 2018

Yeah the error format should filter out the false message now that I think about it, but I don't see any reason to clobber the quickfix list at all in the successful --edit-todo case. If by "preserves error checking" you mean it prevents it from happening outside a rebase, I think the filereadable() check is fine for that. So it skips :make if we can edit the sequence file but runs it if we can't for the error message.

@tpope
Copy link
Owner

tpope commented Dec 31, 2018

Any thoughts on how we might make :Grebase --continue invoke :Gcommit in the case of a resolved merge conflict?

@rbong
Copy link
Contributor Author

rbong commented Jan 3, 2019

I'll have to look into it more

@amadeus
Copy link

amadeus commented Mar 6, 2019

:Grebase --continue from a resolved merge conflict would be very nice :X kinda weird to have to jump out of the :Grebase flow when dealing with conflicts (a very common thing for me, heh)

@tpope
Copy link
Owner

tpope commented Mar 7, 2019

It's driving me nuts. If someone can figure out the conditions of when we need to call git commit, then I can probably figure out the how. The answer should be in the git rebase --continue source code.

@rbong
Copy link
Contributor Author

rbong commented Mar 7, 2019

Rebase detects unresolved conflicts by looking for unstaged changes. Even if you are not in the middle of a merge conflict resolution, it will complain that you are if you have unstaged files.

Similarly, if you have any staged files and you run git rebase --continue, git enters into the commit editor whether you previously had a merge conflict or not. I cannot find the specific code for this but I've confirmed it through experimentation. If you need better than that, let me know. The flow is a little complex and the easiest way to find out what's going on is probably by compiling git with debug information and using gdb to trace it.

Minor note: if there are conflicts on git rebase --continue it will leave a MERGE_MSG... however, deleting this and running --continue results in the same behaviour (including the correct commit message), so it is probably not good to rely on this file at all.

@rbong
Copy link
Contributor Author

rbong commented Mar 12, 2019

My last post was correct but I have actually confirmed it in the source code now. There is only one minor special case to consider.

The main points about how it works are below, but more information is available here if you need to dig into it:

Main takeaways:

  • As suspected, rebase checks to see if there was a merge conflict that needs resolving by looking at staged files. If there are unstaged files, it considers it an unresolved conflict, and if there are staged files, it commits them to resolve any conflicts. There doesn't appear to be any particularly special considerations
  • There may be special considerations if files such as rebase-merge/amend exist already and there are staged files, but the way we're currently handling those files may be sufficient. Practical testing is needed before I go digging into that workflow

I hope there's something in there to help implement this. It's certainly beyond my capabilities to actually add this behaviour to the plugin without some serious investment.

@tpope
Copy link
Owner

tpope commented Apr 6, 2019

I can't imagine I covered every use case but it's now working for the ones I bothered to test.

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

Successfully merging this pull request may close these issues.

3 participants