Re: How can I tell if a SHA1 is a submodule reference?
- From
Avery Pennarun <apenwarr@gmail.com>
- Date
- May 15, 2008, 20:12 UTC
- Message-ID
- <32541b130805151312p7a08a0b7id7c12bc8a04e2aca@mail.gmail.com>
- In-Reply-To
- <7F242E8F-13CF-4BE5-B3E6-85F285391658@ohloh.net>
On 5/15/08, Robin Luckey <robin@ohloh.net> wrote:
> However, is there a simple and reliable way for me to know which SHA1 > hashes refer to such submodule objects? I'd like to simply ignore them.
I don't think there's a straightforward way to do this given *just* the SHA1, in the same way that you can't know the path corresponding to a blob given just its SHA1.
However, if you're looking at a tree that refers to a SHA1, the tree will reference a submodule object as a "commit" instead of a "tree" or "blob". git-ls-tree output looks something like this:
160000 commit ba75ff608fabafeaafeb48d55b125440b5a665bc my_subdir
I think it's reasonable to say that if it's type commit, then it's a submodule. (Note that simply being a submodule doesn't *necessarily* imply that it'll be unavailable; some people like to store all the submodule objects in the local repository.)
Have fun,
Avery