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

Re: git cherry improvements suggestions

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Mar 23, 2011, 13:23 UTC
Message-ID
<AANLkTinXh_Y9ft5Pd5SxOEXvKNm3HLmsiut8WrvFZrdQ@mail.gmail.com>
In-Reply-To
<4D89CF8E.4070100@drmicha.warpmail.net>

On Wed, Mar 23, 2011 at 11:46 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 8 quoted lines
> Piotr Krukowiecki venit, vidit, dixit 23.03.2011 09:11:
>> Hi,
>>
>> Short version:
>>
>> 1. The <limit> is misleading IMO
>
> In what way? Is the documentation wrong?

No, but for me <limit> looks like numeric limit. There is no explicit note in man page that it's a commit.

Show 10 quoted lines
>> 2. Please extend the output to show "full diff"
>> 3. Please add numerical/time <limit>
>> 4. Would it be possible to use "=" for "equivalent change"?
>>
>> Please tell me your opinions.
>
> You will be a happy user of "git log --cherry A...B" instead of "git
> cherry A B". It gives you all the log option (e.g. p for diff) that you
> like and uses "=" rather than "-". It's currently in next and will be in
> the next release.

I've tried it and indeed I'm happy! :) The "git log --cherry-mark --left-right A...B" is what I needed!

Just some stats:
   git log --cherry-mark --left-right --oneline --date-order branch...trunk

lists 1004 commits, takes about 20s and memory peaks to about 670MB twice during the run (I'm on linux with AMD Phenom II X4 945)

With limit it prints X last commits (the limiting seems to take place after all work, on the output list only).

branch..trunk is 551 commits, the other way is 453 commits. 710 commits are found to be "=", 98 "<", 196 ">".

Note, I'm not saying it's too slow, or that it's working incorrectly, I'm just giving real-life stats if anyone was interested. I suspect such checks won't be done frequently.

So thanks for the great improvement!
Show 9 quoted lines
>> 1. man page says: git cherry [-v] [<upstream> [<head> [<limit>]]]
>>
>>    $ git cherry -v master 9_1 20
>>    fatal: Unknown commit 20
>>
>> After reading man page I though the limit is a numeric limit, like "check
>> last 20 commits".
>
> It clearly is the name of a commit in that picture.

I have assumed the limit is numerical and means number of commits. Coming from that assumption it looked like cherry used the limit number as a commit by mistake.

Show 13 quoted lines
>> 2. The cherry currently shows only changes against one branch:
>>
>>    Every commit that doesn’t exist in the <upstream> branch has its id (sha1)
>>    reported[...] The ones that have equivalent change already in the <upstream>
>>    branch are prefixed with a minus (-) sign, and those that only exist in the
>>    <head> branch are prefixed with a plus (+)  symbol
>>
>> So it will not show commits that exist only in <upstream> but not in <head>.
>>
>> In my case changes are transplanted both ways (in general), so I have to check
>> both branches.
>
> You'll be a happy user of "git log --cherry-mark --left-right A...B" :)
Thanks again :)
Show 5 quoted lines
>> 3. I think a numerical limit (or even: time limit etc) of checked commits would
>> be useful, especially in "full diff" mode. Without it would be not
>
> log has a limit argument (-<number>), though I'm not sure it is exactly
> what you want.

I'd be happy if the limiting was done before all the work, so the performance could be improved by that.

For example, it could take <number> last commits from each branch and check only them.

This would help if you wanted to check only last week commits.
Show 14 quoted lines
>> 4. The output format uses "-" to show commits that exist in both branches.
>> I find this unnatural. There probably is a reason for this? But maybe it would
>> be possible to change the symbols? For example:
>>
>>    - commit in upstream only
>>    + commit in head only
>>    = equivalent commit
>>
>> Or "<", ">", " " or any other graphic symbol.
>
> git log --cherry-mark --left-right will use <,=,>
> git log --cherry-mark or --cherry will use *,=
>
> (And yes, you can use it with --graph!)

I've done some quick tests to see how --cherry works, maybe someone will find them useful:

# setup $ echo a > a && git add a && git commit -a -m a $ echo b > b && git add b && git commit -a -m b $ echo a1 > a && git add a1 && git commit -a -m a1 $ echo a1 > a && git add a && git commit -a -m a1 $ git checkout -b topic HEAD^ $ echo b1 > b && git add b && git commit -a -m b1 $ echo c > c && git add c && git commit -a -m c $ git checkout master $ echo d > d && git add d && git commit -a -m d

# cherry pick a1 into topic and b1 into master
$ git log --oneline --graph topic master
* b1f200c a1
* 6b95eb4 c
* ab34325 b1
| * 15ff34f b1
| * d78c15d d
| * ace8ef2 a1
|/
* 9d88558 b
* bd17dd4 a
$ git log --oneline --cherry topic...master
= 15ff34f b1
+ d78c15d d
= ace8ef2 a1
$ git log --oneline --cherry master...topic
= b1f200c a1
+ 6b95eb4 c
= ab34325 b1
$ git log --oneline --cherry -2 topic...master
= 15ff34f b1
+ d78c15d d
$ git log --oneline --cherry -2 master...topic
= b1f200c a1
+ 6b95eb4 c
$ git cherry topic master
- ace8ef21d85b060b98d3f7d8a3b3753ee9b98317
+ d78c15df0ee457f77dab7b0b247735dfec246b65
- 15ff34f8a342b6e8999d0e5d528e0b8875fb8042
$ git cherry master topic
- ab343256684621d5bc68084f1d77f1b8312b6a3b
+ 6b95eb4c01647de623f478219eb932b07b97edc6
- b1f200c49c562517eafd77872bf5394960eee53f
-- 
Piotr Krukowiecki
Previous: Michael J GruberNext: Michael J Gruber
Message 3 of 9 in “git cherry improvements suggestions”
  1. Piotr KrukowieckiMar 23, 2011
  2. Michael J GruberMar 23, 2011
  3. Piotr KrukowieckiMar 23, 2011
  4. Michael J GruberMar 23, 2011
  5. Piotr KrukowieckiMar 23, 2011
  6. Michael J GruberMar 23, 2011
  7. Piotr KrukowieckiMar 23, 2011
  8. Piotr KrukowieckiMar 24, 2011
  9. Michael J GruberMar 24, 2011

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.