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

Re: [PATCH 2/3] merge-base: return fork-point outside reflog

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2017, 09:14 UTC
Message-ID
<xmqqa81njds0.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<4a14c35c-88b0-7bc3-0a6e-c69ed9ec7ee7@grubix.eu>
Michael J Gruber <git@grubix.eu> writes:
Show 6 quoted lines
> I'm still trying to understand what the original intent was: If we
> abstract from the implementation (as we should, as you rightly
> emphasize) and talk about historical tips then we have to ask ourselves:
> - What is "historical"?
> - What is tip?
> - Tip of what, i.e. what is a "branch"?

The feature was meant to be a solution for "upstream rebased the branch I based my work on."

Suppose you did
	git clone $URL
	git checkout -b mytopic origin/topic
	work work work and commit commit commit

and then the next "git fetch" found that remote/origin/topic did not fast-forward, i.e. your upstream rewound and rebuilt the topic.

Now, running
	git rebase origin/topic mytopic

would be a disaster, as it would try to replay all the commits reachable from mytopic on top of the updated origin/topic, but the set of commits reachable from mytopic includes those the upstream used to have, on top of which you based your work, and you are not interested in replaying them at all.

If you remember where you forked your topic from (you should be able to tell from "git log mytopic"), then

	git rebase --onto origin/topic $fork_point mytopic

would be the way to replay "your" work on mytopic on top of the updated upstream.

The reason why "--fork-point" exists is because people wanted to automate the "remember where you forked your topic from" part.

Your upstream might have rewound the tip of topic many times while your repository did not fetch from it (iow, the reflog for origin/topic may not have _all_ the tips of other people observed to be historicallly at the tip of the remote), but that is immaterial for our purpose. As long as you built on top of origin/topic, the fork point must be one of the commits _you_ saw at the tip and it does not matter that you did not constantly fetch to observe all the changes at the remote.

So the answers of these three questions are:
 - "historical": _you_ saw in your repository;
 - "tip": _you_ saw it pointed by the branch you forked your work
   from; and
 - "branch": whatever you consider you based your work on top of,
   typically a remote tracking branch.

Of course, if you are employing a more advanced workflow, you might not have started your mytopic branch at any of the tip. E.g. if you wanted to extend Ben's fsmonitor topic, you would have forked your own topic like

	git checkout -b my-fsmonitor origin/pu^2

after fetching from me, and --fork-point would not be of much help obviously for such a workflow. But such users will use --onto and explicitly specify the fork point so it is outside the scope of the feature.

Previous: Michael J GruberNext: Junio C Hamano
Message 15 of 25 in “RE: merge-base not working as expected when base is ahead”
  1. Ekelhart JakobSep 13, 2017
  2. Michael J GruberSep 14, 2017
  3. 0/3 merge-base --fork-point fixesMichael J Gruber, Sep 14, 2017
  4. Johannes SchindelinSep 14, 2017
  5. Jeff KingSep 14, 2017
  6. 2/3 merge-base: return fork-point outside reflogMichael J Gruber, Sep 14, 2017
  7. Junio C HamanoSep 15, 2017
  8. Phillip WoodSep 15, 2017
  9. Michael J GruberSep 15, 2017
  10. Junio C HamanoSep 15, 2017
  11. Junio C HamanoSep 21, 2017
  12. Michael J GruberSep 21, 2017
  13. Junio C HamanoSep 22, 2017
  14. Michael J GruberSep 22, 2017
  15. Junio C HamanoSep 22, 2017
  16. Junio C HamanoOct 3, 2017
  17. Ekelhart JakobNov 8, 2017
  18. Michael J GruberNov 8, 2017
  19. Junio C HamanoNov 9, 2017
  20. 3/3 merge-base: find fork-point outside partial reflogMichael J Gruber, Sep 14, 2017
  21. Jeff KingSep 14, 2017
  22. 1/3 t6010: test actual test outputMichael J Gruber, Sep 14, 2017
  23. Jeff KingSep 14, 2017
  24. Michael J GruberSep 15, 2017
  25. Jeff KingSep 15, 2017

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.