summaryrefslogtreecommitdiff
path: root/lockfile.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-10-01 10:28:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-01 20:38:41 (GMT)
commit41dd4ffaf99532d8344c90a5b1a060ac1f73b232 (patch)
tree1a543baafc3a2c2dc78ee4c197adf2e4e43cd905 /lockfile.c
parent26f5d3b65fa1b40be570a67f1aaca0e2f085d568 (diff)
downloadgit-41dd4ffaf99532d8344c90a5b1a060ac1f73b232.zip
git-41dd4ffaf99532d8344c90a5b1a060ac1f73b232.tar.gz
git-41dd4ffaf99532d8344c90a5b1a060ac1f73b232.tar.bz2
lockfile: unlock file if lockfile permissions cannot be adjusted
If the call to adjust_shared_perm() fails, lock_file returns -1, which to the caller looks like any other failure to lock the file. So in this case, roll back the lockfile before returning so that the lock file is deleted immediately and the lockfile object is left in a predictable state (namely, unlocked). Previously, the lockfile was retained until process cleanup in this situation. 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 'lockfile.c')
-rw-r--r--lockfile.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lockfile.c b/lockfile.c
index 3df1e83..d74de8d 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -153,6 +153,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)
int save_errno = errno;
error("cannot fix permission bits on %s",
lk->filename);
+ rollback_lock_file(lk);
errno = save_errno;
return -1;
}