Tig: Feature Request: interactive rebase

Created on 28 Jan 2015  路  8Comments  路  Source: jonas/tig

Hi. It would be nice to have interactive rebase script opened inside tig with features similar to main view, i.e. diff of selected commit. Even in read-only mode.

Most helpful comment

Use hotkey
http://agateau.com/2016/starting-an-interactive-rebase-from-tig/

bind main R !git rebase -i %(commit)^
bind diff R !git rebase -i %(commit)^

To trigger rebase with https://github.com/MitMaro/git-interactive-rebase-tool are useful

All 8 comments

I had a plan in mind for that, which consisted of adding a rebase view (that implies --all), which adds a extra column with related actions for the commits (p for pick, r for reword, etc.). The view may have convenient default binding like:

# command line options
bind rebase o rebase-onto
bind rebase u rebase-upstream

# todo-list
bind rebase p rebase-pick
bind rebase r rebase-reword
bind rebase e rebase-edit
bind rebase s rebase-squash
bind rebase f rebase-fixup

# interaction
bind rebase C !git  rebase --continue
bind rebase A !git rebase --abort
bind rebase S !git rebase --skip

The hard part is the interaction. Think if a commit didn't apply, how Tig should react? Also, some features might be to tricky to implement or non-intuitive: think commits order, picking a new commit, or supporting exec? This rebase support would have to be limited on purpose.

Also, a tool or a Tig view would have to be written to handle the todo-list. That way, you could do EDITOR=tig-rebase git rebase -i HEAD~4. Note: the core.editor Git config has priority over environment variables. So if you have set core.editor, you'll have to unset it before executing the command, ultra-boring. And then, you don't want to implement line editing and such in Tig.


The best I could find out actually, is to bind your editor to inspect the highlighted commit while you're editing the todo-list. For instance, Vim users can bind this:

" With Git
:execute "!git show " . split(getline("."), " ")[1]

" Or with Tig
:silent execute "!tig show " . split(getline("."), " ")[1] | redraw!

Regarding the note about the editor. Looking at git-config(1) it looks like there is a special editor for rebase. I didn't look at what git version it requires.

_sequence.editor_

Text editor used by git rebase -i for editing the rebase instruction file. The value is meant to be interpreted by the shell when it is used. It can be overridden by the GIT_SEQUENCE_EDITOR environment variable. When not configured the default commit message editor is used instead.

Regarding the interaction, I think it would have to mirror git-rebase as much as possible. In case of conflicts Tig could show the status view, which would allow to open either a merge tool or manually fix conflicts using an editor. But I think that the user should also have the option to drop into a shell, which might require some logic to detect whether the conflict was resolved when the shell returns.

The whole feature would be nice, but it looks like many corner cases will be hit. the GIT_SEQUENCE_EDITOR="tig rebase" tool can have another binding to pass the todo-list back and forth to the editor (same mecanism that git rebase --edit-todo actually uses). Otherwise, git rebase --interactive with read-only todo-list doesn't really make sense.

@jonas This may be worth looking at for inspiration: https://github.com/MitMaro/git-interactive-rebase-tool

Use hotkey
http://agateau.com/2016/starting-an-interactive-rebase-from-tig/

bind main R !git rebase -i %(commit)^
bind diff R !git rebase -i %(commit)^

To trigger rebase with https://github.com/MitMaro/git-interactive-rebase-tool are useful

See also: hg histedit in Mercurial, which lets you select and move commits in a curses UI.

This would be great!

For me the most frustrating thing when rebasing is the extremely limited commit info that is displayed, only the first line of the commit message. So I find myself hopping between the rebase view, a window with 'git log --stat' and another window where I am git showing commits.

To be able to start a rebase and then interactively expand a commit to show the --stat view and if needed view the diff in a split pane would be amazing.

Also in answer to

Think if a commit didn't apply, how Tig should react?

Would that not be just the same as how you handle rebase-edit, which I guess would be dropping the user into a shell?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seiyeah78 picture seiyeah78  路  7Comments

rominf picture rominf  路  6Comments

kgraefe picture kgraefe  路  8Comments

proski picture proski  路  3Comments

julien-lecomte picture julien-lecomte  路  4Comments