submodule_init: die cleanly on submodules without url defined
commit627fde102515a7807dba89acaa88cb053b38a44a
authorJeff King <peff@peff.net>
Tue, 25 Apr 2017 00:57:47 +0000 (24 20:57 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Apr 2017 02:00:15 +0000 (24 19:00 -0700)
tree3a255ca92f07db454e523baff730b18941eae6a8
parent0202c411edc25940cc381bf317badcdf67670be4
submodule_init: die cleanly on submodules without url defined

When we init a submodule, we try to die when it has no URL
defined:

  url = xstrdup(sub->url);
  if (!url)
  die(...);

But that's clearly nonsense. xstrdup() will never return
NULL, and if sub->url is NULL, we'll segfault.

These two bits of code need to be flipped, so we check
sub->url before looking at it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
t/t7400-submodule-basic.sh