@matheusbsbs / matheus-bagliano / commits / 234b3dae2f
Fork 0

rebase-i: Ignore comments and blank lines in peek_next_command

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Jan 12, 2010 at 16:38 UTC 234b3dae2fe83ae7df2c82194cd5f5eb01fd166d
2 files changed +25 -1
git-rebase--interactive.sh
+1 -1
@@ -338,7 +338,7 @@ make_squash_message () {
338 }
339
340 peek_next_command () {
341 - sed -n "1s/ .*$//p" < "$TODO"
341 + sed -n -e "/^#/d" -e "/^$/d" -e "s/ .*//p" -e "q" < "$TODO"
342 }
343
344 do_next () {
t/t3404-rebase-interactive.sh
+24
@@ -265,6 +265,30 @@ test_expect_success 'squash and fixup generate correct log messages' '
265 git branch -D squash-fixup
266 '
267
268 +test_expect_success 'squash ignores comments' '
269 + git checkout -b skip-comments E &&
270 + base=$(git rev-parse HEAD~4) &&
271 + FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \
272 + EXPECT_HEADER_COUNT=4 \
273 + git rebase -i $base &&
274 + test $base = $(git rev-parse HEAD^) &&
275 + test 1 = $(git show | grep ONCE | wc -l) &&
276 + git checkout to-be-rebased &&
277 + git branch -D skip-comments
278 +'
279 +
280 +test_expect_success 'squash ignores blank lines' '
281 + git checkout -b skip-blank-lines E &&
282 + base=$(git rev-parse HEAD~4) &&
283 + FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \
284 + EXPECT_HEADER_COUNT=4 \
285 + git rebase -i $base &&
286 + test $base = $(git rev-parse HEAD^) &&
287 + test 1 = $(git show | grep ONCE | wc -l) &&
288 + git checkout to-be-rebased &&
289 + git branch -D skip-blank-lines
290 +'
291 +
292 test_expect_success 'squash works as expected' '
293 for n in one two three four
294 do