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

Re: Properties of trees referencing commit objects (mode 160000)?

From
Josh Triplett <josh@joshtriplett.org>
Date
Mar 20, 2016, 18:45 UTC
Message-ID
<20160320184524.GA16064@x>
In-Reply-To
<20160320041803.GC18312@sigill.intra.peff.net>
On Sun, Mar 20, 2016 at 12:18:04AM -0400, Jeff King wrote:
Show 11 quoted lines
> On Sat, Mar 19, 2016 at 03:13:48PM -0700, Josh Triplett wrote:
> 
> > I'm building some tools to track commit objects, and I'm thinking of
> > using submodule-style references to commit objects in tree objects (mode
> > 160000) to do so.  I'm trying to figure out some of the properties of
> > that.
> > 
> > Can a commit object referenced that way live in the same repository,
> > rather than some external repository?
> 
> Yes, it can be in the same repository, but...

Will git clone/checkout/etc handle it properly in that case, in the absence of a .gitmodules file? Or would it only work with custom tools?

Show 9 quoted lines
> > Will git treat such a reference as keeping the commit object (and
> > everything recursively referenced by it) live and reachable?  If that
> > commit object is only reachable by the tree, and not by following the
> > parents of any commit directly referenced from refs/*, will git discard
> > it as unreachable?
> 
> No, we do not follow "gitlinks" like this for reachability. Neither for
> pruning, nor for object transfer via push/fetch. So you'd need to have a
> separate reference to it (or history containing it).

Argh. If I have a pile of disconnected commits, is there anything git *would* follow to see them, other than a pile of refs?

I suppose I could artificially generate a stack of merge commits with those otherwise disconnect commits as parents, which would let me reference them all from a single ref. Still unsatisfying, though.

Also, thanks, "gitlink" was the term I was trying to think of.

(I'd also be tempted to ask whether a patch to teach git to follow gitlinks for reachability and/or object transfer would be acceptable.)

Previous: Jeff KingNext: Jeff King
Message 3 of 9 in “Properties of trees referencing commit objects (mode 160000)?”
  1. Josh TriplettMar 19, 2016
  2. Jeff KingMar 20, 2016
  3. Josh TriplettMar 20, 2016
  4. Jeff KingMar 20, 2016
  5. Josh TriplettMar 20, 2016
  6. Jeff KingMar 21, 2016
  7. Josh TriplettMar 21, 2016
  8. Junio C HamanoMar 20, 2016
  9. Josh TriplettMar 20, 2016

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.