summaryrefslogtreecommitdiff
path: root/lockfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'lockfile.c')
-rw-r--r--lockfile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lockfile.c b/lockfile.c
index 1d18c67ea8..728ce49765 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -318,8 +318,13 @@ int commit_lock_file(struct lock_file *lk)
/* remove ".lock": */
result_file[strlen(result_file) - LOCK_SUFFIX_LEN] = 0;
- if (rename(lk->filename, result_file))
+ if (rename(lk->filename, result_file)) {
+ int save_errno = errno;
+ rollback_lock_file(lk);
+ errno = save_errno;
return -1;
+ }
+
lk->filename[0] = 0;
return 0;
}