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

From: Lea Wiemann <[email-masked]>
Date: Mon, 09 Jun 2008 20:21:09 +0200

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