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

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
Previous: Robin LuckeyNext: Linus Torvalds
Message 2 of 5 in “How can I tell if a SHA1 is a submodule reference?”
  1. Robin LuckeyMay 15, 2008
  2. Avery PennarunMay 15, 2008
  3. Linus TorvaldsMay 15, 2008
  4. Junio C HamanoMay 15, 2008
  5. Robin LuckeyMay 15, 2008

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.