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

Re: [PATCH] cat-file --batch / --batch-check: do not exit if hashes are missing

From
LWLea Wiemann <lewiemann@gmail.com>
Date
Jun 9, 2008, 18:21 UTC
Message-ID
<484D7495.3020407@gmail.com>
In-Reply-To
<484D3CCB.1000508@viscovery.net>
Johannes Sixt wrote:
> With this change an invalid name and a non-existing SHA1 are treated as
> "missing". But an empty name is still an error  [...]: It is the first thing
> that the function checks, and there it exits with return 1.

An empty object name is actually not an error but just yields "SP missing". The "if (!obj_name) return 1;" statement doesn't dereference obj_name, so it checks for null pointers. However, batch_one_object gets called with buf.buf as its obj_name parameter, which according to api-strbuf.txt is never NULL. So probably the check is pointless and can be removed (the tests still pass); someone more knowledgeable than me should confirm this though.

(FWIW, perhaps the original author intended to catch empty input this way, but I'm not convinced that this is even sensible.)

Unrelatedly, does anyone know how to stop sha1_object_info from barfing on non-existent hashes? It causes the annoying "error: unable to find 000..." on stderr if you run "echo 0000000000000000000000000000000000000000 | git-cat-file --batch-check".

-- Lea
Previous: Johannes Sixt
Message 12 of 12 in “cat-file --batch / --batch-check: do not exit if hashes are missing”
  1. cat-file --batch / --batch-check: do not exit if hashes are missingLea Wiemann, Jun 8, 2008
  2. Johannes SchindelinJun 8, 2008
  3. Lea WiemannJun 9, 2008
  4. Johannes SchindelinJun 9, 2008
  5. Lea WiemannJun 9, 2008
  6. Jakub NarebskiJun 9, 2008
  7. Lea WiemannJun 9, 2008
  8. cat-file --batch / --batch-check: do not exit if hashes are missingLea Wiemann, Jun 9, 2008
  9. Junio C HamanoJun 9, 2008
  10. Junio C HamanoJun 9, 2008
  11. Johannes SixtJun 9, 2008
  12. Lea WiemannJun 9, 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.