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

Re: Find out on which branch a commit was originally made

From
ASArtur Skawina <art.08.09@gmail.com>
Date
Sep 20, 2010, 10:58 UTC
Message-ID
<4C973E5B.4090201@gmail.com>
In-Reply-To
<1jp42v5.w5dez21d3nlciM%lists@haller-berlin.de>
On 09/20/10 10:12, Stefan Haller wrote:
> Seth Robertson <in-gitvger@baka.org> wrote:
Show 20 quoted lines
>>          -AA-- subtopic
>>         /     \
>>        A---B---C topic
>>       /         \
>>  D---E---F---G---H---I---J---K---L---M---N master
>>                           \         /
>>                            O---P---Q another-topic
>>
>>
>> In the above example, the subtopic branch merge from AA to C prevents
>> you from finding out what branch B is on using the original script.
> 
> When you say "the original script", are you talking about Artur's
> one-liner or my script?
> 
> My script gives me exactly the information I want in all cases.  For a
> given command $1 and a target branch $2, it shows you all merges that
> were involved in bringing $1 into $2. For example:
> 
>   Called with "B" "master", it returns H

No, it will return both C and H, just like my one-liner; this will be misleading, the user won't be able to figure out where 'B" came from w/o looking at the graph, from output like:

$ git-show-merges-since B master C..... Merge branch 'subtopic' into topic H..... Merge branch 'topic'

The results for 'B' and 'AA' will be exactly the same.

For 'B', the 'C' merge should be omitted; skipping it because 'B' comes in via first parent would probably work, but i can't turn that into a one-liner right now...

On 09/20/10 07:47, Seth Robertson wrote:
Show 14 quoted lines
> I agree 100% that the right answer is topic for B and master for F.
> 
> I know how to get topic for B.  Finding master (and not another-topic)
> for F is difficult because we have to know something that I don't know
> how to get git to tell me: when another-topic branch was created.
> Using git-rev-parse another-topic....master we know what commit
> another-topic and master diverged, but I cannot figure out a way to
> discover which branch was created at that point and which branch
> pre-existed (obviously for master we know, but if this was a
> supertopic branch we would not).  I thought about using merge
> direction for subsequent merges as a hint, but we don't know if the
> second branch has been permanently been merged or not, if there was a
> K->P merge and Q-M did not happen (yet) then we would give the wrong
> branch name.

Oh, if there would be no 'Q->M' merge and both branches would still be "live", 'both' is certainly the right answer.

If 'another-topic' was merged into another branch (like in the example graph) and is dead at this point, i think skipping it is the correct decision -- there could be many such branches and presenting a long list of candidates won't really help the user.

Given history as in the graph and a /live/ 'another-topic' -- hmm, if there are just a few such refs maybe showing them would be ok.

artur
Previous: Stefan HallerNext: Artur Skawina
Message 19 of 33 in “Find out on which branch a commit was originally made”
  1. Stefan HallerSep 18, 2010
  2. Ævar Arnfjörð BjarmasonSep 18, 2010
  3. Ævar Arnfjörð BjarmasonSep 18, 2010
  4. Tor ArntsenSep 18, 2010
  5. Stefan HallerSep 18, 2010
  6. Artur SkawinaSep 18, 2010
  7. Stefan HallerSep 19, 2010
  8. Clemens BuchacherSep 19, 2010
  9. Artur SkawinaSep 19, 2010
  10. Stefan HallerSep 19, 2010
  11. Artur SkawinaSep 19, 2010
  12. Robin RosenbergSep 19, 2010
  13. Seth RobertsonSep 19, 2010
  14. Artur SkawinaSep 19, 2010
  15. Seth RobertsonSep 19, 2010
  16. Artur SkawinaSep 20, 2010
  17. Seth RobertsonSep 20, 2010
  18. Stefan HallerSep 20, 2010
  19. Artur SkawinaSep 20, 2010
  20. Artur SkawinaSep 20, 2010
  21. Seth RobertsonSep 21, 2010
  22. Artur SkawinaSep 21, 2010
  23. ANNOUNCE git-what-branch (was Re: Find out on which branch a commit was originally made)Seth Robertson, Sep 22, 2010
  24. Artur SkawinaSep 22, 2010
  25. Seth RobertsonSep 22, 2010
  26. Stephen BashSep 23, 2010
  27. Ævar Arnfjörð BjarmasonSep 23, 2010
  28. Artur SkawinaSep 23, 2010
  29. Artur SkawinaSep 24, 2010
  30. Seth RobertsonSep 24, 2010
  31. Seth RobertsonSep 23, 2010
  32. Stefan HallerSep 20, 2010
  33. Bryan DrewerySep 24, 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.