Re: rebase autosquash doesn't recognise a chain of fixups
Carlos Martín Nieto <cmn@elego.de> writes:
Show 13 quoted lines
> Say I have the following commits:
>
> 5154127 fixup! fixup! one
> 0d130d8 fixup! one
> 0869d30 one
>
> because I keep executing `git commit -a --fixup HEAD`. When I want to
> squash them all into 0869d30, I do `git rebase -i --autosquash
> 0869d30^` and I get
>
> pick 0869d30 one
> fixup 0d130d8 fixup! one
> pick 5154127 fixup! fixup! one
The way Kevin's d3d7a42 (rebase: better rearranging of fixup!/squash! lines with --autosquash, 2010-11-04) series works is to match "fixup!" only with "pick"; a later "fixup!" never matches an earlier "fixup!" but a "pick" can be matched against more than one "fixup!".
I think one way to make this work is to fix what Pat did in d71b8ba (commit: --fixup option for use with rebase --autosquash, 2010-11-02).
Perhaps like this, but I'll leave additions of test scripts to t3415 to others.
-- >8 --
Subject: commit --fixup: do not duplicate "fixup! " at the beginning
The "rebase -i" command can match more than one "fixup!" against a single "pick" in the right order thanks to the earlier d3d7a42 (rebase: better rearranging of fixup!/squash! lines with --autosquash, 2010-11-04), but a "fixup!" entry is never matched with another "fixup!" entry.
When creating a commit marked to fix up an earlier commit with --fixup, we can mark it to look for the original and fix that one up.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/commit.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 67757e9..b3c4d63 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -668,6 +668,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
ctx.output_encoding = get_commit_output_encoding();
format_commit_message(commit, "fixup! %s\n\n",
&sb, &ctx);
+ while (!prefixcmp(sb.buf, "fixup! fixup!"))
+ strbuf_splice(&sb, 0, 7, "", 0);
hook_arg1 = "message";
} else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)