Commit bb9272dd by Carlos Martín Nieto

filebuf cleanup: only unlink lockfile if we've opened it

Add a check for the file descriptor in git_filebuf_cleanup. Without
it, an existing lockfile would be deleted if we tried to acquire it
(but failed, as the lockfile already existed).

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent 8102a961
...@@ -75,7 +75,7 @@ void git_filebuf_cleanup(git_filebuf *file) ...@@ -75,7 +75,7 @@ void git_filebuf_cleanup(git_filebuf *file)
if (file->fd >= 0) if (file->fd >= 0)
gitfo_close(file->fd); gitfo_close(file->fd);
if (file->path_lock && gitfo_exists(file->path_lock) == GIT_SUCCESS) if (file->fd >= 0 && file->path_lock && gitfo_exists(file->path_lock) == GIT_SUCCESS)
gitfo_unlink(file->path_lock); gitfo_unlink(file->path_lock);
if (file->digest) if (file->digest)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment