branch.c: if remote is not config'd for branch, don't try delete push config
commitdfef873f3ddbabf5d380d679e9b76d033b14e01a
authorBrandon Casey <drafnel@gmail.com>
Thu, 16 Jul 2009 21:26:15 +0000 (16 16:26 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jul 2009 23:31:10 +0000 (16 16:31 -0700)
treef81c9a4ab238099142f1013f2d4cb2c956623b17
parent4f67cc0d57d7e330e4db8ac054a39e76b8cb8ad1
branch.c: if remote is not config'd for branch, don't try delete push config

If a remote is not configured for the branch configuration being deleted,
then don't try to delete the remote.<remote>.push configuration for the
branch.  When the remote is not configured, branch->remote_name is not
filled in.  When this NULL branch->remote_name is passed to strbuf_addf()
it will result in an attempt to remove a bogus configuration statement in
the best case (i.e. "remote.(null).push" for platforms which guard against
supplying NULL to a %s conversion spec) and a segfault in the worst case.

So check whether branch->remote_name is non-NULL before trying to use it.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c