git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] rebase -i: fixup fixup! fixup!

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 25, 2013, 21:36 UTC
Message-ID
<7va9md27qw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1372190294-sup-1398@pimlott.net>
Andrew Pimlott <andrew@pimlott.net> writes:
Show 27 quoted lines
> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
> index c84854a..6b2e1c8 100644
> --- a/Documentation/git-rebase.txt
> +++ b/Documentation/git-rebase.txt
> @@ -389,7 +389,9 @@ squash/fixup series.
>  	the same ..., automatically modify the todo list of rebase -i
>  	so that the commit marked for squashing comes right after the
>  	commit to be modified, and change the action of the moved
> -	commit from `pick` to `squash` (or `fixup`).
> +	commit from `pick` to `squash` (or `fixup`).  Ignores subsequent
> +	"fixup! " or "squash! " after the first, in case you referred to an
> +	earlier fixup/squash with `git commit --fixup/--squash`.
>  +
>  This option is only valid when the '--interactive' option is used.
>  +
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index f953d8d..54ed4c3 100644
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -689,7 +689,18 @@ rearrange_squash () {
>  		case "$message" in
>  		"squash! "*|"fixup! "*)
>  			action="${message%%!*}"
> -			rest="${message#*! }"
> +			rest=$message
> +			# ignore any squash! or fixup! after the first
> +			while : ; do
Style:
	while :
        do
Show 35 quoted lines
> +				case "$rest" in
> +				"squash! "*|"fixup! "*)
> +					rest="${rest#*! }"
> +					;;
> +				*)
> +					break
> +					;;
> +				esac
> +			done
>  			echo "$sha1 $action $rest"
>  			# if it's a single word, try to resolve to a full sha1 and
>  			# emit a second copy. This allows us to match on both message
> diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
> index a1e86c4..1a3f40a 100755
> --- a/t/t3415-rebase-autosquash.sh
> +++ b/t/t3415-rebase-autosquash.sh
> @@ -193,4 +193,53 @@ test_expect_success 'use commit --squash' '
>  	test_auto_commit_flags squash 2
>  '
>  
> +test_auto_fixup_fixup () {
> +	git reset --hard base &&
> +	echo 1 >file1 &&
> +	git add -u &&
> +	test_tick &&
> +	git commit -m "$1! first" &&
> +	echo 2 >file1 &&
> +	git add -u &&
> +	test_tick &&
> +	git commit -m "$1! $2! first" &&
> +	git tag "final-$1-$2" &&
> +	test_tick &&
> +	git rebase --autosquash -i HEAD^^^^ &&
> +	git log --oneline >actual &&
> +	test_pause &&
This patch obviously hasn't been tested.  It breaks without -v.
Show 7 quoted lines
> +	if [ "$1" = "fixup" ]; then
> +		test_line_count = 3 actual
> +	elif [ "$1" = "squash" ]; then
> +		test_line_count = 4 actual
> +	else
> +		false
> +	fi &&
Style
	if test "$1" = "fixup"
	then
        	...
	elif test "$1" = "squash"
	then
		...
(you got the idea).
Show 22 quoted lines
> +	git diff --exit-code "final-$1-$2" &&
> +	test 2 = "$(git cat-file blob HEAD^:file1)" &&
> +	if [ "$1" = "fixup" ]; then
> +		test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
> +	elif [ "$1" = "squash" ]; then
> +		test 3 = $(git cat-file commit HEAD^ | grep first | wc -l)
> +	else
> +		false
> +	fi
> +}
> +
> +test_expect_success 'fixup! fixup!' '
> +	test_auto_fixup_fixup fixup fixup
> +'
> +
> +test_expect_success 'fixup! squash!' '
> +	test_auto_fixup_fixup fixup squash
> +'
> +
> +test_expect_success 'squash! squash!' '
> +	test_auto_fixup_fixup squash squash
> +'
This does not seem to pass for me.
Show 5 quoted lines
> +test_expect_success 'squash! fixup!' '
> +	test_auto_fixup_fixup squash fixup
> +'
> +
>  test_done
Previous: Andrew PimlottNext: Junio C Hamano
Message 14 of 23 in “rebase --autosquash does not handle fixup! of fixup!”
  1. Andrew PimlottJun 11, 2013
  2. Thomas RastJun 11, 2013
  3. rebase -i: fixup fixup! fixup!Andrew Pimlott, Jun 14, 2013
  4. Andrew PimlottJun 15, 2013
  5. Junio C HamanoJun 15, 2013
  6. Junio C HamanoJun 16, 2013
  7. Thomas RastJun 16, 2013
  8. Junio C HamanoJun 17, 2013
  9. Thomas RastJun 17, 2013
  10. Junio C HamanoJun 17, 2013
  11. Andrew PimlottJun 25, 2013
  12. Junio C HamanoJun 25, 2013
  13. Andrew PimlottJun 25, 2013
  14. Junio C HamanoJun 25, 2013
  15. Junio C HamanoJun 25, 2013
  16. Junio C HamanoJun 25, 2013
  17. Andrew PimlottJun 25, 2013
  18. Andrew PimlottJun 26, 2013
  19. Junio C HamanoJun 26, 2013
  20. Andrew PimlottJun 27, 2013
  21. Andrew PimlottJun 27, 2013
  22. Junio C HamanoJun 27, 2013
  23. Andrew PimlottJun 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.