]> git.ipfire.org Git - thirdparty/git.git/commitdiff
lockfile: unlock file if lockfile permissions cannot be adjusted
authorMichael Haggerty <mhagger@alum.mit.edu>
Wed, 1 Oct 2014 10:28:11 +0000 (12:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Oct 2014 20:38:41 +0000 (13:38 -0700)
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>
lockfile.c

index 3df1e8306a4471e3c2868f16609bb70a5f106ca1..d74de8d329a4adc3e9c2b158365292c36a37a10d 100644 (file)
@@ -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;
                }