summaryrefslogtreecommitdiff
path: root/builtin/reflog.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-12-12 09:56:45 +0100
committerJunio C Hamano <gitster@pobox.com>2014-12-12 11:43:47 -0800
commit2e376b3156ff30dcd359b7c424fcbdbab5ec7709 (patch)
tree616f2e2ca0c1caa636ebfd0d078d12b533f2bc07 /builtin/reflog.c
parent524127afbf8b98350bcebe3fc1f7600fce191716 (diff)
downloadgit-2e376b3156ff30dcd359b7c424fcbdbab5ec7709.tar.gz
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>
Diffstat (limited to 'builtin/reflog.c')
-rw-r--r--builtin/reflog.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/builtin/reflog.c b/builtin/reflog.c
index ff51dbfc0a..37b33c9d70 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -368,9 +368,11 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
lock = lock_any_ref_for_update(refname, sha1, 0, NULL);
if (!lock)
return error("cannot lock ref '%s'", refname);
+ if (!reflog_exists(refname)) {
+ unlock_ref(lock);
+ return 0;
+ }
log_file = git_pathdup("logs/%s", refname);
- if (!reflog_exists(refname))
- goto finish;
if (!cmd->dry_run) {
newlog_path = git_pathdup("logs/%s.lock", refname);
cb.newlog = fopen(newlog_path, "w");
@@ -419,7 +421,7 @@ static int expire_reflog(const char *refname, const unsigned char *sha1,
clear_commit_marks(tip_commit, REACHABLE);
}
}
- finish:
+
if (cb.newlog) {
if (fclose(cb.newlog)) {
status |= error("%s: %s", strerror(errno),