Re: Properties of trees referencing commit objects (mode 160000)?
From: Josh Triplett <josh@joshtriplett.org>
Date: 2016-06-15 23:08:50
On Sun, Mar 20, 2016 at 03:30:27PM -0700, Junio C Hamano wrote:
Josh Triplett [off-list ref] writes:quoted
On Sun, Mar 20, 2016 at 12:18:04AM -0400, Jeff King wrote:quoted
On Sat, Mar 19, 2016 at 03:13:48PM -0700, Josh Triplett wrote:quoted
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?That depends on the definition of "proper". The default "proper" way for the core Git for submodules/gitlinks is to create an empty directory. If you want to populate a working tree for that, you'd need "git submodule" support, but because you are writing "some tools" on your own, there probably is a reason why you do not want to use "git submodule", so I am guessing that your definition of "proper" does not match either core Git or "git submodule" considers "proper"? In which case you would need to implement your own semantics (you may not even want to have an empty directory there, for example).
I can live with "creates an empty directory and doesn't choke or complain". I'd kinda hoped that git might notice it already has the commit, and do something like checking out the files of that commit into the working directory, but it isn't critical. - Josh Triplett