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

Re: [PATCH 2/2] commit: use a priority queue in merge base functions

From
Jeff King <peff@peff.net>
Date
Aug 30, 2012, 21:48 UTC
Message-ID
<20120830214802.GB18636@sigill.intra.peff.net>
In-Reply-To
<7vy5kws5jn.fsf@alter.siamese.dyndns.org>
On Thu, Aug 30, 2012 at 09:33:48AM -0700, Junio C Hamano wrote:
Show 14 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > The script originally comes from here:
> >
> >   http://thread.gmane.org/gmane.comp.version-control.git/33566/focus=33852
> >
> > and the discussion implies that the AUTHOR_DATEs were added to avoid a
> > race condition with the timestamps. But why would that ever have worked?
> 
> I do not see how AUTHOR_DATE would affect anything there, either,
> other than to give reprodusible object names.  The test only sets
> committer-date upfront, so without setting author-date, you would
> still get different object names on commits.  Which suggests me that
> there may be something that tiebreaks based on object names?

Hmm. I wouldn't think so. The order should come from timestamps, with ties broken by order of insertion, which in turn comes from traversal, which depends only on parent order. We do check some raw sha1s in the expected output, but it is only for blobs, not commits. I guess it could be some weirdness inside merge-recursive, though, and not part of the merge-base computation.

So I really don't know how AUTHOR_DATE would change anything. And indeed, after removing them it still passes on my machine.

However, I think I may understand why it fails if you tweak the committer dates.

When my unstable-queue was used, I noticed that the merge bases returned were the same (as you would expect), but that they came in a different order. Which makes sense, as the order of multiple bases would not necessarily be deterministic (they do not have an ancestry relationship, or they would not be merge bases).

So the issue is that when you do a recursive merge with multiple bases, the order in which you visit the recursive bases is going to impact the exact conflicts you see. In theory, after the merge is done, you're going to be at the same state, but the conflicts you see along the way will be different. And it is this conflicted state that the test is looking at.

The current test expects a particular order of merge bases based on the same-second commit timestamps. There is no race condition because of the setting of GIT_COMMITTER_DATE at the beginning (and _that_ is the real thing that fixed the race conditions Dscho saw in the thread above; the AUTHOR_DATE was just a red herring).

So the test is not broken or racy, which is good. It is just testing something that is somewhat of an implementation detail. We could switch it to use test_tick, and then adjust the expected output to look for the expected conflict that git happens to generate in that case. But that is no better than the current behavior.

But I'm not sure there is a way to test what it wants to test (that we hit a conflict that involves one of the recursive merge bases) without relying on the implementation detail. So I'm inclined to just leave it in place.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 22 of 27 in “optimize fast-forward checks”
  1. 0/5 optimize fast-forward checksJunio C Hamano, Aug 27, 2012
  2. 1/5 in_merge_bases(): support only one "other" commitJunio C Hamano, Aug 27, 2012
  3. 2/5 receive-pack: use in_merge_bases() for fast-forward checkJunio C Hamano, Aug 27, 2012
  4. 3/5 http-push: use in_merge_bases() for fast-forward checkJunio C Hamano, Aug 27, 2012
  5. 4/5 in_merge_bases(): omit unnecessary redundant common ancestor reductionJunio C Hamano, Aug 27, 2012
  6. 5/5 (BROKEN) get_merge_bases_many(): walk from many tips in parallelJunio C Hamano, Aug 27, 2012
  7. Junio C HamanoAug 28, 2012
  8. Junio C HamanoAug 28, 2012
  9. Junio C HamanoAug 28, 2012
  10. Jeff KingAug 29, 2012
  11. 1/2 basic priority queue implementationJeff King, Aug 29, 2012
  12. 2/2 commit: use a priority queue in merge base functionsJeff King, Aug 29, 2012
  13. Junio C HamanoAug 29, 2012
  14. Jeff KingAug 29, 2012
  15. Jeff KingAug 29, 2012
  16. Jeff KingAug 29, 2012
  17. Jeff KingAug 29, 2012
  18. Jeff KingAug 30, 2012
  19. Jeff KingAug 30, 2012
  20. Jeff KingAug 30, 2012
  21. Junio C HamanoAug 30, 2012
  22. Jeff KingAug 30, 2012
  23. Junio C HamanoAug 30, 2012
  24. Junio C HamanoAug 30, 2012
  25. Jeff KingAug 30, 2012
  26. Junio C HamanoAug 30, 2012
  27. Junio C HamanoAug 29, 2012

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.