rollback_lock_file(): exit early if lock is not active

Eliminate a layer of nesting. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Ronnie Sahlberg <sahlberg@google.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Oct 1, 2014 at 12:28 UTC 9085f8e279146a31ea8bbd102b6c97f5cb22dcdc
1 file changed +7 -6
lockfile.c
+7 -6
@@ -276,10 +276,11 @@ int hold_locked_index(struct lock_file *lk, int die_on_error)
276
277 void rollback_lock_file(struct lock_file *lk)
278 {
279 - if (lk->filename[0]) {
280 - if (lk->fd >= 0)
281 - close(lk->fd);
282 - unlink_or_warn(lk->filename);
283 - lk->filename[0] = 0;
284 - }
279 + if (!lk->filename[0])
280 + return;
281 +
282 + if (lk->fd >= 0)
283 + close(lk->fd);
284 + unlink_or_warn(lk->filename);
285 + lk->filename[0] = 0;
286 }