upload-pack: do not check NULL return of lookup_unknown_object
authorJeff King <peff@peff.net>
Fri, 13 Mar 2015 04:42:25 +0000 (00:42 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Mar 2015 06:21:16 +0000 (23:21 -0700)
We check whether the return value of lookup_unknown_object
is NULL, but some code paths dereference it before our
check. This turns out not to be capable of causing a
segfault, though. The lookup_unknown_object function will
never return NULL, since the whole point is to allocate an
object struct if it does not find an existing one. So the
code here is not wrong, it is just confusing. Let's just
drop the NULL check.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c
index af2a13acc6d54c07e301c87de678bf2ca1863d11..4bc2dc3607ee6b86c773f8bedd803cc5134412c7 100644 (file)
@@ -688,8 +688,6 @@ static int mark_our_ref(const char *refname, const unsigned char *sha1)
                o->flags |= HIDDEN_REF;
                return 1;
        }
-       if (!o)
-               die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
        o->flags |= OUR_REF;
        return 0;
 }