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

Re: rebase --autosquash does not handle fixup! of fixup!

From
Thomas Rast <trast@inf.ethz.ch>
Date
Jun 11, 2013, 18:50 UTC
Message-ID
<87obbc8otc.fsf@hexa.v.cablecom.net>
In-Reply-To
<20130611180530.GA18488@oinkpad.pimlott.net>
Andrew Pimlott <andrew@pimlott.net> writes:
Show 29 quoted lines
> git rebase -i --autosquash does not handle a fixup! of a fixup!, such as
> the history:
>
>     aaaaaaa fix nasty bug
>     ...
>     bbbbbbb fixup! fix nasty bug
>     ...
>     ccccccc fixup! fixup! fix nasty bug
>
> --autosquash produces:
>
>     pick aaaaaaa fix nasty bug
>     fixup bbbbbbb fixup! fix nasty bug
>     ...
>     pick ccccccc fixup! fixup! fix nasty bug
>
> This defeats the workflow I was hoping to use:
>
>     git commit -m 'fix nasty bug'
>     ...
>     git commit --fixup :/nasty
>     ...
>     git commit --fixup :/nasty
>
> The second :/nasty resolves to the previous fixup, not the initial
> commit.  I could have made the regular expression more precise, but this
> would be a hassle.
>
> Would a change to support fixup! fixup! be considered?

Sure, why not. You could start with something like the patch below (untested). If that happens to work, just add a test and a good commit message.

diff --git i/git-rebase--interactive.sh w/git-rebase--interactive.sh
index f953d8d..798ae81 100644
--- i/git-rebase--interactive.sh
+++ w/git-rebase--interactive.sh
@@ -689,7 +689,17 @@ rearrange_squash () {
 		case "$message" in
 		"squash! "*|"fixup! "*)
 			action="${message%%!*}"
-			rest="${message#*! }"
+			rest=$message
+			while : ; do
+				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
-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Andrew PimlottNext: Andrew Pimlott
Message 2 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.