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

Re: git cherry not marking commits with equivalent upstream

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Jul 1, 2010, 20:41 UTC
Message-ID
<20100701204151.GA6354@atjola.homenet>
In-Reply-To
<1278012954-sup-3724@pimlott.net>
On 2010.07.01 12:38:45 -0700, Andrew Pimlott wrote:
Show 42 quoted lines
> The documentation for git-cherry says it marks changes in the current
> checkout that have an "equivalent" change in the upstream branch.  It
> even says it's useful when feeding patches upstream by email instead of
> git, which is what I'm doing (with CVS instead of email).  But it
> doesn't seem to work for me.
> 
> I'll simulate cloning an upstream repo, creating and commiting a patch,
> then sending it via email upstream to have it applied there, then
> pulling the upstream commit (the upstream repo is a, mine is b):
> 
>     ~% mkdir a && cd a
>     ~/a% git init
>     Initialized empty Git repository in /home/andrew/a/.git/
>     ~/a% touch a
>     ~/a% git add a
>     ~/a% git commit -m 1
>     [master (root-commit) be4fa74] 1
>      0 files changed, 0 insertions(+), 0 deletions(-)
>      create mode 100644 a
>     ~/a% git clone . ../b && cd ../b
>     Initialized empty Git repository in /home/andrew/b/.git/
>     ~/b% echo test > a
>     ~/b% git add a
>     ~/b% git commit -m 2
>     [master 551e90a] 2
>      1 files changed, 1 insertions(+), 0 deletions(-)
>     ~/b% cd ../a
>     ~/a% echo test > a
>     ~/a% git add a
>     ~/a% git commit -m 3
>     [master bb13e6c] 3
>      1 files changed, 1 insertions(+), 0 deletions(-)
>     ~/a% cd ../b
>     ~/b% git pull
>     remote: Counting objects: 5, done.
>     remote: Total 3 (delta 0), reused 0 (delta 0)
>     Unpacking objects: 100% (3/3), done.
>     From /home/andrew/a/.
>        be4fa74..bb13e6c  master     -> origin/master
>     Merge made by recursive.
>     ~/b% cat a
>     test
pull = fetch + merge, so your history in "b" looks like this:
  2 (origin/master)
 / \
1   M (master)
 \ /
  3

So "2" is common to both branches and thus ignored by cherry. If you just fetch instead of merging, you get the result you expected:

doener@atjola:b (master) $ git fetch 
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/doener/y/a
   4815708..dfbbb81  master     -> origin/master
doener@atjola:b (master) $ git cherry
- 2544e5a7f5d6b545d9e24ba9dcac74861b0bf15c

But once I merge: doener@atjola:b (master) $ git merge origin/master Merge made by recursive.

doener@atjola:b (master) $ git cherry
+ 2544e5a7f5d6b545d9e24ba9dcac74861b0bf15c
Björn
Previous: Andrew PimlottNext: Andrew Pimlott
Message 3 of 13 in “git cherry not marking commits with equivalent upstream”
  1. Andrew PimlottJul 1, 2010
  2. Andrew PimlottJul 1, 2010
  3. Björn SteinbrinkJul 1, 2010
  4. Andrew PimlottJul 1, 2010
  5. Documentation: 'cherry' does not cope well with merges from upstreamJonathan Nieder, Jul 1, 2010
  6. Andrew PimlottJul 1, 2010
  7. Jonathan NiederJul 1, 2010
  8. Junio C HamanoJul 1, 2010
  9. Jonathan NiederJul 2, 2010
  10. Jonathan NiederJul 2, 2010
  11. Michael J GruberJul 2, 2010
  12. Jonathan NiederJul 2, 2010
  13. Michael J GruberJul 2, 2010

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.