git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Pat Notz <patnotz@gmail.com>
Cc: "Kevin Ballard" <kevin@sb.org>,
	git@vger.kernel.org, "Carlos Martín Nieto" <cmn@elego.de>
Subject: Re: rebase autosquash doesn't recognise a chain of fixups
Date: Tue, 05 Apr 2011 10:34:26 -0700	[thread overview]
Message-ID: <7v4o6cob4t.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20110405154100.GC16031@bee.lab.cmartin.tk> ("Carlos Martín Nieto"'s message of "Tue, 5 Apr 2011 17:41:00 +0200")

Carlos Martín Nieto <cmn@elego.de> writes:

>  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)

  parent reply	other threads:[~2011-04-05 17:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 15:41 rebase autosquash doesn't recognise a chain of fixups Carlos Martín Nieto
2011-04-05 15:48 ` Vincent van Ravesteijn
2011-04-05 16:03   ` Carlos Martín Nieto
2011-04-05 17:34 ` Junio C Hamano [this message]
2011-04-05 18:02   ` Kevin Ballard
2011-04-05 18:27     ` Junio C Hamano
     [not found]       ` <BANLkTimqvu7c559_AQ6yLxPACOxD0ciNxQ@mail.gmail.com>
2011-04-05 21:03         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v4o6cob4t.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=cmn@elego.de \
    --cc=git@vger.kernel.org \
    --cc=kevin@sb.org \
    --cc=patnotz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).