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

Determining whether you have a commit locally, in a partial clone?

From
Tao Klerks <tao@klerks.biz>
Date
Jun 20, 2023, 11:26 UTC
Message-ID
<CAPMMpohiTzANyhzL-mS-gg2kzbOEOiDktNbdwEXBKy9uL0-JgA@mail.gmail.com>
Hi folks,

I "discovered" today that when you're in a partial clone, naive tests to check for whether you have a commit locally no longer work - they fetch the commit on-demand:

git cat-file -t SOME_HASH_NOT_IN_REFSPEC git rev-list SOME_HASH_NOT_IN_REFSPEC

I didn't realize this until today: even commits can be "filtered out" by partial clone, so any reference to a commit that is not found locally must be resolved transparently via jit-fetch.

I'm optimizing some stuff for users, so I need to know whether a given commit exists locally or not... but I can't seem to figure out how!

I tried using "git rev-list"'s "--exclude-promisor-objects" option, but I guess I don't understand what that's supposed to do. In my case it just made a simple check like "git rev-list --exclude-promisor-objects SOME_HASH_NOT_IN_REFSPEC" take forever (10 mins and counting).

I confirmed that removing (commenting out) the "remote.origin.promisor" and "remote.origin.partialclonefilter" config keys achieves my objective, but I can't figure out how to do it safely; "-c remote.origin.promisor=false -c remote.origin.partialclonefilter=" does *not* seem to work. The existence of a "remote.origin.partialclonefilter" value, even if it is empty, appears to override the "remote.origin.promisor=false" setting.

As far as I can tell, config values cannot be unset with "-c" - in fact I see that credential.helper was granted special support for empty string as a way of signalling "no credential helper" by Jeff King in 2016.

So I guess I have two questions:
* Is there any way to run a single git command in a "don't use
promisors" context?
* Is the fact that "-c remote.origin.partialclonefilter=" doesn't work
for temporarily unsetting the filter a bug/issue to be resolved?

Thanks, Tao

Next: Tao Klerks
Message 1 of 9 in “Determining whether you have a commit locally, in a partial clone?”
  1. Tao KlerksJun 20, 2023
  2. Tao KlerksJun 20, 2023
  3. Junio C HamanoJun 20, 2023
  4. Tao KlerksJun 20, 2023
  5. Jeff KingJun 21, 2023
  6. Tao KlerksJun 20, 2023
  7. Jeff KingJun 21, 2023
  8. Tao KlerksJun 21, 2023
  9. Jeff KingJun 27, 2023

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.