* [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands
[not found] <7vr5pw3pwp.fsf@alter.siamese.dyndns.org>
@ 2010-01-12 15:38 ` Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did Michael Haggerty
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Michael Haggerty @ 2010-01-12 15:38 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes.Schindelin, Michael Haggerty
Here is v2 of the patch (now patch series) for making "rebase -i"
ignore comments and blank lines while it is processing blocks of
squash/fixup commands.
Please note that this version applies to "next", not "master", because
it depends on some changes to t/t3404-rebase-interactive.sh that were
made in mh/rebase-fixup. (This dependency is superficial and could be
removed if necessary.)
The first patch in this series is not essential to the functionality
but I found it useful when debugging the tests.
Michael Haggerty (3):
lib-rebase: Provide clearer debugging info about what the editor did
lib-rebase: Allow comments and blank lines to be added to the rebase
script
rebase-i: Ignore comments and blank lines in peek_next_command
git-rebase--interactive.sh | 2 +-
t/lib-rebase.sh | 26 +++++++++++++++++++-------
t/t3404-rebase-interactive.sh | 24 ++++++++++++++++++++++++
3 files changed, 44 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did
2010-01-12 15:38 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Michael Haggerty
@ 2010-01-12 15:38 ` Michael Haggerty
2010-01-13 6:55 ` Junio C Hamano
2010-01-12 15:38 ` [PATCHv2 2/3] lib-rebase: Allow comments and blank lines to be added to the rebase script Michael Haggerty
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Michael Haggerty @ 2010-01-12 15:38 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes.Schindelin, Michael Haggerty
(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 <mhagger@alum.mit.edu>
---
t/lib-rebase.sh | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index f4dda02..0fce595 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"
--
1.6.6.140.ga53ad
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 2/3] lib-rebase: Allow comments and blank lines to be added to the rebase script
2010-01-12 15:38 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did Michael Haggerty
@ 2010-01-12 15:38 ` Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 3/3] rebase-i: Ignore comments and blank lines in peek_next_command Michael Haggerty
2010-01-12 16:37 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Johannes Schindelin
3 siblings, 0 replies; 6+ messages in thread
From: Michael Haggerty @ 2010-01-12 15:38 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes.Schindelin, Michael Haggerty
(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 <mhagger@alum.mit.edu>
---
t/lib-rebase.sh | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 0fce595..0db8250 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:
#
-# "[<lineno1>] [<lineno2>]..."
+# "<lineno>" -- 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.
+# "<cmd> <lineno>" -- 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;;
--
1.6.6.140.ga53ad
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 3/3] rebase-i: Ignore comments and blank lines in peek_next_command
2010-01-12 15:38 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 2/3] lib-rebase: Allow comments and blank lines to be added to the rebase script Michael Haggerty
@ 2010-01-12 15:38 ` Michael Haggerty
2010-01-12 16:37 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Johannes Schindelin
3 siblings, 0 replies; 6+ messages in thread
From: Michael Haggerty @ 2010-01-12 15:38 UTC (permalink / raw)
To: git; +Cc: gitster, Johannes.Schindelin, Michael Haggerty
Previously, blank lines and/or comments within a series of
squash/fixup commands would confuse "git rebase -i" into thinking that
the series was finished. It would therefore require the user to edit
the commit message for the squash/fixup commits seen so far. Then,
after continuing, it would ask the user to edit the commit message
again.
Ignore comments and blank lines within a group of squash/fixup
commands, allowing them to be processed in one go.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
git-rebase--interactive.sh | 2 +-
t/t3404-rebase-interactive.sh | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 27479db..2e56e64 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -340,7 +340,7 @@ make_squash_message () {
}
peek_next_command () {
- sed -n "1s/ .*$//p" < "$TODO"
+ sed -n -e "/^#/d" -e "/^$/d" -e "s/ .*//p" -e "q" < "$TODO"
}
do_next () {
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ea26115..d9382e4 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -265,6 +265,30 @@ test_expect_success 'squash and fixup generate correct log messages' '
git branch -D squash-fixup
'
+test_expect_success 'squash ignores comments' '
+ git checkout -b skip-comments E &&
+ base=$(git rev-parse HEAD~4) &&
+ FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \
+ EXPECT_HEADER_COUNT=4 \
+ git rebase -i $base &&
+ test $base = $(git rev-parse HEAD^) &&
+ test 1 = $(git show | grep ONCE | wc -l) &&
+ git checkout to-be-rebased &&
+ git branch -D skip-comments
+'
+
+test_expect_success 'squash ignores blank lines' '
+ git checkout -b skip-blank-lines E &&
+ base=$(git rev-parse HEAD~4) &&
+ FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \
+ EXPECT_HEADER_COUNT=4 \
+ git rebase -i $base &&
+ test $base = $(git rev-parse HEAD^) &&
+ test 1 = $(git show | grep ONCE | wc -l) &&
+ git checkout to-be-rebased &&
+ git branch -D skip-blank-lines
+'
+
test_expect_success 'squash works as expected' '
for n in one two three four
do
--
1.6.6.140.ga53ad
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands
2010-01-12 15:38 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Michael Haggerty
` (2 preceding siblings ...)
2010-01-12 15:38 ` [PATCHv2 3/3] rebase-i: Ignore comments and blank lines in peek_next_command Michael Haggerty
@ 2010-01-12 16:37 ` Johannes Schindelin
3 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2010-01-12 16:37 UTC (permalink / raw)
To: Michael Haggerty; +Cc: git, gitster
Hi,
On Tue, 12 Jan 2010, Michael Haggerty wrote:
> Here is v2 of the patch (now patch series) for making "rebase -i" ignore
> comments and blank lines while it is processing blocks of squash/fixup
> commands.
Me likee.
Thanks,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did
2010-01-12 15:38 ` [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did Michael Haggerty
@ 2010-01-13 6:55 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2010-01-13 6:55 UTC (permalink / raw)
To: Michael Haggerty; +Cc: git, Johannes.Schindelin
Very nice; thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-01-13 6:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <7vr5pw3pwp.fsf@alter.siamese.dyndns.org>
2010-01-12 15:38 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 1/3] lib-rebase: Provide clearer debugging info about what the editor did Michael Haggerty
2010-01-13 6:55 ` Junio C Hamano
2010-01-12 15:38 ` [PATCHv2 2/3] lib-rebase: Allow comments and blank lines to be added to the rebase script Michael Haggerty
2010-01-12 15:38 ` [PATCHv2 3/3] rebase-i: Ignore comments and blank lines in peek_next_command Michael Haggerty
2010-01-12 16:37 ` [PATCHv2 0/3] rebase-i: Ignore comments and blank lines among squash/fixup commands Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).