expire_reflog(): return early if the reference has no reflog

There is very little cleanup needed if the reference has no reflog. If we move the initialization of log_file down a bit, there's even less. So instead of jumping to the cleanup code at the end of the function, just do the cleanup and return inline. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Dec 12, 2014 at 09:56 UTC 2e376b3156ff30dcd359b7c424fcbdbab5ec7709
1 file changed +5 -3
builtin/reflog.c
+5 -3
@@ -368,9 +368,11 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
368 lock = lock_any_ref_for_update(refname, sha1, 0, NULL);
369 if (!lock)
370 return error("cannot lock ref '%s'", refname);
371 + if (!reflog_exists(refname)) {
372 + unlock_ref(lock);
373 + return 0;
374 + }
375 log_file = git_pathdup("logs/%s", refname);
372 - if (!reflog_exists(refname))
373 - goto finish;
376 if (!cmd->dry_run) {
377 newlog_path = git_pathdup("logs/%s.lock", refname);
378 cb.newlog = fopen(newlog_path, "w");
@@ -419,7 +421,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
421 clear_commit_marks(tip_commit, REACHABLE);
422 }
423 }
422 - finish:
424 +
425 if (cb.newlog) {
426 if (fclose(cb.newlog)) {
427 status |= error("%s: %s", strerror(errno),