diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2014-10-01 10:28:12 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-10-01 20:38:42 (GMT) |
commit | ebb8e380e98e83f32c1cc04200d3749ab4c0b90a (patch) | |
tree | 578ad31c440cda905a63cce2e11a43655f582efa /lockfile.c | |
parent | 41dd4ffaf99532d8344c90a5b1a060ac1f73b232 (diff) | |
download | git-ebb8e380e98e83f32c1cc04200d3749ab4c0b90a.zip git-ebb8e380e98e83f32c1cc04200d3749ab4c0b90a.tar.gz git-ebb8e380e98e83f32c1cc04200d3749ab4c0b90a.tar.bz2 |
hold_lock_file_for_append(): release lock on errors
If there is an error copying the old contents to the lockfile, roll
back the lockfile before exiting so that the lockfile is not held
until process cleanup.
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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -219,13 +219,13 @@ int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags) if (errno != ENOENT) { if (flags & LOCK_DIE_ON_ERROR) die("cannot open '%s' for copying", path); - close(fd); + rollback_lock_file(lk); return error("cannot open '%s' for copying", path); } } else if (copy_fd(orig_fd, fd)) { if (flags & LOCK_DIE_ON_ERROR) exit(128); - close(fd); + rollback_lock_file(lk); return -1; } return fd; |