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

Re: [PATCH] replace: stop replace lookup when reaching a self-reference

From
Jeff King <peff@peff.net>
Date
Aug 29, 2019, 13:52 UTC
Message-ID
<20190829135213.GB1797@sigill.intra.peff.net>
In-Reply-To
<20190829112249.32262-1-mh@glandium.org>
On Thu, Aug 29, 2019 at 08:22:49PM +0900, Mike Hommey wrote:
> It is possible to end up in situations where a replace ref points to
> itself. In that case, it would seem better to stop the lookup rather
> than try to follow the link infinitely and fail with "replace depth too
> high".

I don't think this is worth doing. It's just a special case (a 2-node cycle in the replace graph) of a more general one (an n-node cycle).

We catch the general case with the depth counter (though of course there are other techniques, which we could debate). Is it worth adding extra code to cover this special one?

> I'm not entirely sure whether it's actually worth fixing. Arguably, `git
> replace` should also avoid the footgun in the first place (although in
> my case, it wasn't due to `git replace` itself).
Yes, if "git replace $OID $OID" does not complain, it probably should.

Perhaps it should even confirm that the replacement can be resolved, and does not point to the original object. That covers the n-node case, as well.

-Peff
Previous: Mike Hommey
Message 2 of 2 in “replace: stop replace lookup when reaching a self-reference”
  1. replace: stop replace lookup when reaching a self-referenceMike Hommey, Aug 29, 2019
  2. Jeff KingAug 29, 2019

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.