From 6741aa6c399dec3d8f0b25699a73b8fcf974d702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 7 Oct 2009 08:13:23 +0200 Subject: Teach 'rebase -i' the command "reword" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it easier to edit just the commit message for a commit using 'git rebase -i' by introducing the "reword" command. Signed-off-by: Björn Gustavsson Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/lib-rebase.sh') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 260a231933..62f452c8ea 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -9,8 +9,8 @@ # # "[] []..." # -# If a line number is prefixed with "squash" or "edit", the respective line's -# command will be replaced with the specified one. +# If a line number is prefixed with "squash", "edit", or "reword", the +# respective line's command will be replaced with the specified one. set_fake_editor () { echo "#!$SHELL_PATH" >fake-editor.sh @@ -32,7 +32,7 @@ cat "$1".tmp action=pick for line in $FAKE_LINES; do case $line in - squash|edit) + squash|edit|reword) action="$line";; *) echo sed -n "${line}s/^pick/$action/p" -- cgit v1.2.3 From 0205e72f088322a70a77643a7cd2d8b23ee07e14 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Mon, 7 Dec 2009 10:20:59 +0100 Subject: Add a command "fixup" to rebase --interactive The command is like "squash", except that it discards the commit message of the corresponding commit. Signed-off-by: Michael Haggerty Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 't/lib-rebase.sh') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 62f452c8ea..f4dda02b5a 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -9,8 +9,9 @@ # # "[] []..." # -# If a line number is prefixed with "squash", "edit", or "reword", the -# respective line's command will be replaced with the specified one. +# If a line number is prefixed with "squash", "fixup", "edit", or +# "reword", the respective line's command will be replaced with the +# specified one. set_fake_editor () { echo "#!$SHELL_PATH" >fake-editor.sh @@ -32,7 +33,7 @@ cat "$1".tmp action=pick for line in $FAKE_LINES; do case $line in - squash|edit|reword) + squash|fixup|edit|reword) action="$line";; *) echo sed -n "${line}s/^pick/$action/p" -- cgit v1.2.3 From f64b4856243a9ea9445068a0989c71a8915c3862 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Tue, 12 Jan 2010 16:38:34 +0100 Subject: lib-rebase: Provide clearer debugging info about what the editor did (For testing "rebase -i"): Output the "rebase -i" command script before and after the edits, to make it clearer what the editor did. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 't/lib-rebase.sh') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index f4dda02b5a..0fce5952ce 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -29,6 +29,7 @@ test -z "$EXPECT_COUNT" || test -z "$FAKE_LINES" && exit grep -v '^#' < "$1" > "$1".tmp rm -f "$1" +echo 'rebase -i script before editing:' cat "$1".tmp action=pick for line in $FAKE_LINES; do @@ -36,12 +37,12 @@ for line in $FAKE_LINES; do squash|fixup|edit|reword) action="$line";; *) - echo sed -n "${line}s/^pick/$action/p" - sed -n "${line}p" < "$1".tmp sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" action=pick;; esac done +echo 'rebase -i script after editing:' +cat "$1" EOF test_set_editor "$(pwd)/fake-editor.sh" -- cgit v1.2.3 From 05c95dbe44b42f9c3f7efe6793d311a26e1b8181 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Tue, 12 Jan 2010 16:38:35 +0100 Subject: lib-rebase: Allow comments and blank lines to be added to the rebase script (For testing "rebase -i"): Support new action types in $FAKE_LINES to allow comments and blank lines to be added to the "rebase -i" command list. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 't/lib-rebase.sh') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 0fce5952ce..0db8250c58 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -5,13 +5,20 @@ # - override the commit message with $FAKE_COMMIT_MESSAGE, # - amend the commit message with $FAKE_COMMIT_AMEND # - check that non-commit messages have a certain line count with $EXPECT_COUNT -# - rewrite a rebase -i script with $FAKE_LINES in the form +# - rewrite a rebase -i script as directed by $FAKE_LINES. +# $FAKE_LINES consists of a sequence of words separated by spaces. +# The following word combinations are possible: # -# "[] []..." +# "" -- add a "pick" line with the SHA1 taken from the +# specified line. # -# If a line number is prefixed with "squash", "fixup", "edit", or -# "reword", the respective line's command will be replaced with the -# specified one. +# " " -- add a line with the specified command +# ("squash", "fixup", "edit", or "reword") and the SHA1 taken +# from the specified line. +# +# "#" -- Add a comment line. +# +# ">" -- Add a blank line. set_fake_editor () { echo "#!$SHELL_PATH" >fake-editor.sh @@ -36,6 +43,10 @@ for line in $FAKE_LINES; do case $line in squash|fixup|edit|reword) action="$line";; + "#") + echo '# comment' >> "$1";; + ">") + echo >> "$1";; *) sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" action=pick;; -- cgit v1.2.3 From 959c0d06eafd7723517c953e80ee1a60881c373b Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Thu, 14 Jan 2010 06:54:48 +0100 Subject: t3404: Test the commit count in commit messages generated by "rebase -i" The first line of commit messages generated for "rebase -i" squash/fixup commits includes a count of the number of commits that are being combined. Add machinery to check that this count is correct, and add such a check to some test cases. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 't/lib-rebase.sh') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 0db8250c58..2d922ae43c 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -2,9 +2,10 @@ # After setting the fake editor with this function, you can # -# - override the commit message with $FAKE_COMMIT_MESSAGE, +# - override the commit message with $FAKE_COMMIT_MESSAGE # - amend the commit message with $FAKE_COMMIT_AMEND # - check that non-commit messages have a certain line count with $EXPECT_COUNT +# - check the commit count in the commit message header with $EXPECT_HEADER_COUNT # - rewrite a rebase -i script as directed by $FAKE_LINES. # $FAKE_LINES consists of a sequence of words separated by spaces. # The following word combinations are possible: @@ -25,6 +26,9 @@ set_fake_editor () { cat >> fake-editor.sh <<\EOF case "$1" in */COMMIT_EDITMSG) + test -z "$EXPECT_HEADER_COUNT" || + test "$EXPECT_HEADER_COUNT" = $(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1") || + exit test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" exit -- cgit v1.2.3 From 30c9e919b6ef33b0427a3ad784ed9e951ea48648 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Fri, 22 Jan 2010 10:22:30 +0100 Subject: rebase -i: Enclose sed command substitution in quotes Reported by: Johannes Sixt Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- t/lib-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/lib-rebase.sh') diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 2d922ae43c..6aefe27593 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -27,7 +27,7 @@ set_fake_editor () { case "$1" in */COMMIT_EDITMSG) test -z "$EXPECT_HEADER_COUNT" || - test "$EXPECT_HEADER_COUNT" = $(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1") || + test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" || exit test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" -- cgit v1.2.3