[PATCH 3/5] branch_get: return early on error
- From
Jeff King <peff@peff.net>
- Date
- Jan 8, 2014, 09:35 UTC
- Message-ID
- <20140108093500.GC15720@sigill.intra.peff.net>
- In-Reply-To
- <20140108093338.GA15659@sigill.intra.peff.net>
Right now we simply check if "ret" is valid before doing further processing. As we add more processing, this will become more and more cumbersome. Instead, let's just check whether "ret" is invalid and return early with the error.
Signed-off-by: Jeff King <peff@peff.net> --- remote.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/remote.c b/remote.c index a89efab..a773004 100644 --- a/remote.c +++ b/remote.c @@ -1543,7 +1543,10 @@ struct branch *branch_get(const char *name) ret = current_branch; else ret = make_branch(name, 0); - if (ret && ret->remote_name) { + if (!ret) + return NULL; + + if (ret->remote_name) { ret->remote = remote_get(ret->remote_name); if (ret->merge_nr) { int i;
-- 1.8.5.2.500.g8060133