git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Andrew Pimlott" <andrew@pimlott.net>, git <git@vger.kernel.org>,
	"Frédéric Brière" <fbriere@fbriere.net>,
	"Jeff King" <peff@peff.net>,
	"Björn Steinbrink" <B.Steinbrink@gmx.de>
Subject: Re: [PATCH] Documentation: 'cherry' does not cope well with merges from upstream
Date: Fri, 02 Jul 2010 09:46:37 +0200	[thread overview]
Message-ID: <4C2D995D.2020708@drmicha.warpmail.net> (raw)
In-Reply-To: <20100701210919.GA4283@burratino>

Jonathan Nieder venit, vidit, dixit 01.07.2010 23:09:
> Although ‘git cherry’ is advertised simply to list commits from
> <topic> that have not been merged into <upstream>, internally it
> works by checking for patches in <upstream>..<topic> that do not
> match a patch in <topic>..<upstream>.  This is fast because there

...and it says so in the very first line of the manpage.

> are not many patches to check, and it makes sense semantically
> since even if a new patch patches an old patch from <upstream>,
> it cannot be said to have been merged upstream unless it was
> applied there at some point after the <topic> and <upstream>
> branches diverged.
> 
> But.  If the <topic> branch later merges from <upstream>, it
> throws a spanner in the works and for such a history ‘git cherry’
> is not very useful at all.

I actually think I've reported this before, but I don't mind :)
I keep (topic) branches for my git.git patches. git cherry is helpful
here. When a patch is applied, I merge the corresponding commit (i.e.
Junio's version) to my topic branch to mark it as applied and to have a
nice way of comparing the applied version to the submitted one. At that
point git cherry stops being useful.

> 
> Example:
> 
>  o---o---F---X'---G---U [upstream]
>           \        \
>            X----Y---M---T [topic]
> 
> Suppose the author of the ‘topic’ branch starts from upstream
> commit F and makes a few changes.  One is applied upstream, and
> additionally there is some other useful upstream change, so he
> performs a merge to include the upstream updates into topic.
> The expected output from ‘cherry’ is:
> 
>  + T
>  + Y
>  - X
> 
> Consider the author of a different branch, also called ‘topic’, but
> this one starts from commit G.  Some infrastructure from an existing 
> branch is needed, so first she merges that.  Then she adds her own
> commit.  The expected output from ‘cherry’ is:
> 
>  + T
>  + Y
>  + X
> 
> since none of the new commits have been applied upstream since
> the fork point.
> 
> ‘cherry’ cannot distinguish between these two cases, in part because
> it does not distinguish between parents in a merge commit.
> 
> Add a BUGS section to explain the problem.

This is not a bug. git cherry works exactly as described.

At worst, it is a misfeature.

git cherry would be more useful if you could specify a "limit" which is
an ancestor of "fork-point", not only descendants.

> 
> Thoughts?  Improvements?

Allow general "limit" :)

> 
>  Documentation/git-cherry.txt |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
> index fed115a..83e3bdc 100644
> --- a/Documentation/git-cherry.txt
> +++ b/Documentation/git-cherry.txt
> @@ -59,6 +59,21 @@ OPTIONS
>  <limit>::
>  	Do not report commits up to (and including) limit.
>  
> +BUGS

+DISCUSSION

> +----
> +'git cherry' does not cope well with merges from upstream on the
> +working branch.  Any commits after the original fork point and

...which is the wrong way round anyways ;)

> +before the latest merge from upstream will be reported as not found
> +in <upstream>.
> +
> +                       ____*____*____*_____*__> <upstream>
> +                      /                     \
> +   original fork point                       \
> +                      \__+__+__+__+__+__+__+__*_> <head>
> +
> +While these commits are part of upstream..head, their upstream
> +counterparts are not in head..upstream.

git-cherry(1) never speaks about upstream..head nor head..upstream. It
uses "fork-point", and a merge creates a new "fork-point", i.e.
merge-base. I think it would be good to keep like that in order to avoid
that very misunderstanding. In fact, git cherry is about left and right
commits in upstream...head.

The second paragraph of "DESCRIPTION" may cause confusion when read
without the first one, though.

Michael

  parent reply	other threads:[~2010-07-02  7:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01 19:38 git cherry not marking commits with equivalent upstream Andrew Pimlott
2010-07-01 19:40 ` Andrew Pimlott
2010-07-01 20:41 ` Björn Steinbrink
2010-07-01 21:17   ` Andrew Pimlott
2010-07-01 21:09 ` [PATCH] Documentation: 'cherry' does not cope well with merges from upstream Jonathan Nieder
2010-07-01 21:33   ` Andrew Pimlott
2010-07-01 21:35   ` Jonathan Nieder
2010-07-01 23:52   ` Junio C Hamano
2010-07-02  0:51     ` Jonathan Nieder
2010-07-02  1:04   ` Jonathan Nieder
2010-07-02  7:46   ` Michael J Gruber [this message]
2010-07-02  8:18     ` Jonathan Nieder
2010-07-02  9:23       ` Michael J Gruber

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=4C2D995D.2020708@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=B.Steinbrink@gmx.de \
    --cc=andrew@pimlott.net \
    --cc=fbriere@fbriere.net \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@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).