git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avery Pennarun <apenwarr@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Jon Seymour <jon.seymour@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Is there something like a git format-patch --squash?
Date: Thu, 18 Feb 2010 16:56:30 -0500	[thread overview]
Message-ID: <32541b131002181356n633418e1jb608dfa71e5f8a5b@mail.gmail.com> (raw)
In-Reply-To: <20100218203440.GA8110@coredump.intra.peff.net>

On Thu, Feb 18, 2010 at 3:34 PM, Jeff King <peff@peff.net> wrote:
> On Thu, Feb 18, 2010 at 02:45:54PM -0500, Avery Pennarun wrote:
>> In the above, in the 'else' clause, what I really wanted was something like:
>>
>>    git format-patch --stdout --squash $parent..$commit
>>
>> with one big "| git am" at the end of the loop.
>
> I don't think there is a way to do it automagically. Obviously you can
> use diff (as you did) to produce the diff, but how should the many
> commit messages be combined?

Something like what merge --squash does would be fine, I think.

As it happens, the script I wrote ends up using the commit message
from merge commits (since those are the ones that end up including all
the patches from their side branch), which is precisely equivalent to
how it would look in a "linearizing" SCM like svn or cvs.

I happen to have merge.summary=true in my ~/.gitconfig so my merge
commits have extra information in them, though.

> Worst case, you could probably do it yourself by echoing the mail
> headers yourself, throwing all of the commit messages in the body, and
> then doing the diff:

True.  But format-patch already has the code for that, so it's kind of
error-prone to duplicate it.

> (also, do you really need $parent? In
> --first-parent --reverse, isn't it always going to be $commit^1?).

Good point.  That script was quickly hacked together after a few
iterations that previously did more important things with $parent.

> But I think you can do it without diff application by just re-using the
> tree-state of each merge:
>
>  git rev-list --first-parent --reverse $from..$to |
>  last=$from
>  while read commit; do
>    last=`git cat-file commit $commit |
>          sed '1,/^$/d' |
>          git commit-tree $commit^{tree} -p $from`
>  done
>  git update-ref refs/heads/new $last

I don't think that works, since commit-tree takes the commit message
on stdin but the other stuff via environment variables.  Which is too
bad, really, at least for this case.

Have fun,

Avery

      reply	other threads:[~2010-02-18 21:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 19:45 Is there something like a git format-patch --squash? Avery Pennarun
2010-02-18 19:46 ` Avery Pennarun
2010-02-18 20:34 ` Jeff King
2010-02-18 21:56   ` Avery Pennarun [this message]

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=32541b131002181356n633418e1jb608dfa71e5f8a5b@mail.gmail.com \
    --to=apenwarr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jon.seymour@gmail.com \
    --cc=peff@peff.net \
    /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).