@@ -911,4 +911,20 @@ test_expect_success 'rebase -i --root fixup root commit' 'test0=$(gitcat-filecommitHEAD|grep-c^parent\ )'+test_expect_success'rebase --edit-todo does not works on non-interactive rebase''+gitcheckoutconflict-branch&&+test_must_failgitrebase--ontoHEAD~2HEAD~&&+test_must_failgitrebase--edit-todo&&+gitrebase--abort+'
It _might_ be that you simply inherited sloppiness from surrounding
existing tests, but what happens when a test _before_ this test
failed? Is "git checkout conflict-branch" sufficient to bring you
to a sensible state where this test would succeed? I'd prefer to
see a defensive "git reset --hard &&" before the first "checkout".
The same for the next one.
+test_expect_success 'rebase --edit-todo can be used to modify todo' '
+ git checkout no-conflict-branch^0 &&
+ FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
+ FAKE_LINES="2 1" git rebase --edit-todo &&
+ git rebase --continue
+ test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+ test L = $(git cat-file commit HEAD | sed -ne \$p)
+'
+
test_done
@@ -115,6 +115,23 @@ mark_action_done () {fi}+append_todo_help(){+cat>>"$todo"<<EOF+#+# Commands:+# p, pick = use commit+# r, reword = use commit, but edit the commit message+# e, edit = use commit, but stop for amending+# s, squash = use commit, but meld into previous commit+# f, fixup = like "squash", but discard this commit's log message+# x, exec = run command (the rest of the line) using shell+#+# These lines can be re-ordered; they are executed from top to bottom.+#+# If you remove a line here THAT COMMIT WILL BE LOST.+EOF+}+ make_patch(){sha1_and_parents="$(gitrev-list--parents-1"$1")"case"$sha1_and_parents"in
@@ -901,18 +918,10 @@ test -n "$cmd" && add_exec_commands "$todo" cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto+EOF+append_todo_help+cat>>"$todo"<<EOF#-# Commands:-# p, pick = use commit-# r, reword = use commit, but edit the commit message-# e, edit = use commit, but stop for amending-# s, squash = use commit, but meld into previous commit-# f, fixup = like "squash", but discard this commit's log message-# x, exec = run command (the rest of the line) using shell-#-# These lines can be re-ordered; they are executed from top to bottom.-#-# If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.# EOF
@@ -911,4 +911,22 @@ test_expect_success 'rebase -i --root fixup root commit' 'test0=$(gitcat-filecommitHEAD|grep-c^parent\ )'+test_expect_success'rebase --edit-todo does not works on non-interactive rebase''+gitreset--hard&&+gitcheckoutconflict-branch&&+test_must_failgitrebase--ontoHEAD~2HEAD~&&+test_must_failgitrebase--edit-todo&&+gitrebase--abort+'++test_expect_success'rebase --edit-todo can be used to modify todo''+gitreset--hard&&+gitcheckoutno-conflict-branch^0&&+FAKE_LINES="edit 1 2 3"gitrebase-iHEAD~3&&+FAKE_LINES="2 1"gitrebase--edit-todo&&+gitrebase--continue+testM=$(gitcat-filecommitHEAD^|sed-ne\$p)&&+testL=$(gitcat-filecommitHEAD|sed-ne\$p)+'+ test_done
From: Andrew Wong <hidden> Date: 2016-06-15 22:54:46
This allows users to edit the todo file while they're stopped in the
middle of an interactive rebase. When this action is executed, all
comments from the original todo file are stripped, and new help messages
are appended to the end.
Signed-off-by: Andrew Wong <redacted>
---
Documentation/git-rebase.txt | 5 ++++-
git-rebase--interactive.sh | 17 +++++++++++++++++
git-rebase.sh | 13 +++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
@@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD. --skip:: Restart the rebasing process by skipping the current patch.+--edit-todo::+ Edit the todo list during an interactive rebase.+ -m:: --merge:: Use merging strategies to rebase. When the recursive (default) merge
@@ -792,6 +792,23 @@ skip)do_rest;;+edit-todo)+sed-e'/^#/d'<"$todo">"$todo".new+mv-f"$todo".new"$todo"+append_todo_help+cat>>"$todo"<<EOF+#+# You are editing the todo file of an ongoing interactive rebase.+# To continue rebase after editing, run:+# git rebase --continue+#+EOF++git_sequence_editor"$todo"||+die_abort"Could not execute editor"++exit+;;esac gitvarGIT_COMMITTER_IDENT>/dev/null||
@@ -306,6 +311,11 @@ thenfifi+iftest"$action"="edit-todo"&&test"$type"!="interactive"+then+die"$(gettext"The --edit-todo action can only be used during interactive rebase.")"+fi+case"$action"incontinue)# Sanity check
@@ -338,6 +348,9 @@ abort)rm-r"$state_dir"exit;;+edit-todo)+run_specific_rebase+;;esac# Make sure no rebase is in progress
I guess you should add --edit-todo to OPTIONS_SPEC in git-rebase.sh as
well. The OPTIONS_SPEC needs another little update too. I have
included a patch at the end of this email that you include in a
re-roll.
+ git_sequence_editor "$todo" ||
+ die_abort "Could not execute editor"
die_abort seems a little harsh -- it will discard the rebase state.
Plain "die" would be better, I think.
Also, if you even need to break the line after the || operator, you
might want to indent the remainder by one tab. This file is quite
consistent in using that style, although I don't know what the
preferred style is in general in git.
It looks like this could be trivially combined with the previous case
arm, making the match "--continue|--skip|--abort|--edit-todo)".
-->8--
Author: Martin von Zweigbergk [off-list ref]
rebase usage: subcommands can not be combined with -i
Since 95135b0 (rebase: stricter check of standalone sub command,
2011-02-06), git-rebase has not allowed to use -i together with
e.g. --continue. Yet, when rebase started using OPTIONS_SPEC in
45e2acf (rebase: define options in OPTIONS_SPEC, 2011-02-28), the
usage message included
git-rebase [-i] --continue | --abort | --skip
Remove the "[-i]" from this line.
Signed-off-by: Martin von Zweigbergk [off-list ref]
From: Andrew Wong <hidden> Date: 2016-06-15 22:54:47
Made the fixes as suggested by Martin.
Martin: Good points. Thanks!
Andrew Wong (3):
rebase -i: Refactor help messages for todo file
rebase -i: Teach "--edit-todo" action
rebase -i: Add tests for "--edit-todo"
Martin von Zweigbergk (1):
rebase usage: subcommands can not be combined with -i
Documentation/git-rebase.txt | 5 ++++-
git-rebase--interactive.sh | 48 +++++++++++++++++++++++++++++++++----------
git-rebase.sh | 13 ++++++++++--
t/t3404-rebase-interactive.sh | 18 ++++++++++++++++
4 files changed, 70 insertions(+), 14 deletions(-)
--
1.7.12.318.g79683ba.dirty
From: Andrew Wong <hidden> Date: 2016-06-15 22:54:47
From: Martin von Zweigbergk <redacted>
Since 95135b0 (rebase: stricter check of standalone sub command,
2011-02-06), git-rebase has not allowed to use -i together with e.g.
--continue. Yet, when rebase started using OPTIONS_SPEC in 45e2acf
(rebase: define options in OPTIONS_SPEC, 2011-02-28), the usage message
included
git-rebase [-i] --continue | --abort | --skip
Remove the "[-i]" from this line.
Signed-off-by: Martin von Zweigbergk <redacted>
Signed-off-by: Andrew Wong <redacted>
---
git-rebase.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -115,6 +115,23 @@ mark_action_done () {fi}+append_todo_help(){+cat>>"$todo"<<EOF+#+# Commands:+# p, pick = use commit+# r, reword = use commit, but edit the commit message+# e, edit = use commit, but stop for amending+# s, squash = use commit, but meld into previous commit+# f, fixup = like "squash", but discard this commit's log message+# x, exec = run command (the rest of the line) using shell+#+# These lines can be re-ordered; they are executed from top to bottom.+#+# If you remove a line here THAT COMMIT WILL BE LOST.+EOF+}+ make_patch(){sha1_and_parents="$(gitrev-list--parents-1"$1")"case"$sha1_and_parents"in
@@ -901,18 +918,10 @@ test -n "$cmd" && add_exec_commands "$todo" cat>>"$todo"<<EOF# Rebase $shortrevisions onto $shortonto+EOF+append_todo_help+cat>>"$todo"<<EOF#-# Commands:-# p, pick = use commit-# r, reword = use commit, but edit the commit message-# e, edit = use commit, but stop for amending-# s, squash = use commit, but meld into previous commit-# f, fixup = like "squash", but discard this commit's log message-# x, exec = run command (the rest of the line) using shell-#-# These lines can be re-ordered; they are executed from top to bottom.-#-# If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.# EOF
@@ -911,4 +911,22 @@ test_expect_success 'rebase -i --root fixup root commit' 'test0=$(gitcat-filecommitHEAD|grep-c^parent\ )'+test_expect_success'rebase --edit-todo does not works on non-interactive rebase''+gitreset--hard&&+gitcheckoutconflict-branch&&+test_must_failgitrebase--ontoHEAD~2HEAD~&&+test_must_failgitrebase--edit-todo&&+gitrebase--abort+'++test_expect_success'rebase --edit-todo can be used to modify todo''+gitreset--hard&&+gitcheckoutno-conflict-branch^0&&+FAKE_LINES="edit 1 2 3"gitrebase-iHEAD~3&&+FAKE_LINES="2 1"gitrebase--edit-todo&&+gitrebase--continue+testM=$(gitcat-filecommitHEAD^|sed-ne\$p)&&+testL=$(gitcat-filecommitHEAD|sed-ne\$p)+'+ test_done
From: Andrew Wong <hidden> Date: 2016-06-15 22:54:47
This allows users to edit the todo file while they're stopped in the
middle of an interactive rebase. When this action is executed, all
comments from the original todo file are stripped, and new help messages
are appended to the end.
Signed-off-by: Andrew Wong <redacted>
---
Documentation/git-rebase.txt | 5 ++++-
git-rebase--interactive.sh | 17 +++++++++++++++++
git-rebase.sh | 13 +++++++++++--
3 files changed, 32 insertions(+), 3 deletions(-)
@@ -245,6 +245,9 @@ leave out at most one of A and B, in which case it defaults to HEAD. --skip:: Restart the rebasing process by skipping the current patch.+--edit-todo::+ Edit the todo list during an interactive rebase.+ -m:: --merge:: Use merging strategies to rebase. When the recursive (default) merge
@@ -792,6 +792,23 @@ skip)do_rest;;+edit-todo)+sed-e'/^#/d'<"$todo">"$todo".new+mv-f"$todo".new"$todo"+append_todo_help+cat>>"$todo"<<EOF+#+# You are editing the todo file of an ongoing interactive rebase.+# To continue rebase after editing, run:+# git rebase --continue+#+EOF++git_sequence_editor"$todo"||+die"Could not execute editor"++exit+;;esac gitvarGIT_COMMITTER_IDENT>/dev/null||
@@ -306,6 +307,11 @@ thenfifi+iftest"$action"="edit-todo"&&test"$type"!="interactive"+then+die"$(gettext"The --edit-todo action can only be used during interactive rebase.")"+fi+case"$action"incontinue)# Sanity check
@@ -338,6 +344,9 @@ abort)rm-r"$state_dir"exit;;+edit-todo)+run_specific_rebase+;;esac# Make sure no rebase is in progress
From: Martin von Zweigbergk <hidden> Date: 2016-06-15 22:54:47
On Mon, Sep 17, 2012 at 6:28 PM, Andrew Wong [off-list ref] wrote:
+ test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+ test L = $(git cat-file commit HEAD | sed -ne \$p)
I couldn't find "$" (match last line) in the POSIX man page for sed.
Besides, I think $(git show -s --format=%s HEAD) reads better.
For future reference, and if you haven't already, you may want to
install manpages-posix (or manpages-posix-dev?) and then you can run
e.g. "man 1p sed" to see the POSIX man page for sed.
From: Andrew Wong <hidden> Date: 2016-06-15 22:54:47
On 09/18/12 00:58, Martin von Zweigbergk wrote:
On Mon, Sep 17, 2012 at 6:28 PM, Andrew Wong [off-list ref] wrote:
quoted
+ test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+ test L = $(git cat-file commit HEAD | sed -ne \$p)
I couldn't find "$" (match last line) in the POSIX man page for sed.
Besides, I think $(git show -s --format=%s HEAD) reads better.
It's under "Addresses in sed":
... a '$' character that addresses the last line of input ...
from:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/sed.html
Various places in that test get the content of files that way, so I
thought it's better to just follow the rest of the test. I agree that
there are better ways to achieve the same thing though.
From: Johannes Sixt <hidden> Date: 2016-06-15 22:54:48
From: Johannes Sixt <redacted>
We have now an explicit UI to edit the todo sheet and need not disclose
the name of the file.
Signed-off-by: Johannes Sixt <redacted>
---
git-rebase--interactive.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -575,11 +575,12 @@ do_next () {;;*)warn"Unknown command: $command$sha1$rest"+fixtodo="Please fix this using 'git rebase --edit-todo'."ifgitrev-parse--verify-q"$sha1">/dev/nullthen-die_with_patch$sha1"Please fix this in the file $todo."+die_with_patch$sha1"$fixtodo"else-die"Please fix this in the file $todo."+die"$fixtodo"fi;;esac