diff options
author | Jeff King <peff@peff.net> | 2017-09-05 08:14:33 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-09-06 17:19:53 +0900 |
commit | 83a3069a3895de81fea720ffa6a3e47f9400fe04 (patch) | |
tree | 4d07619006dd562db5f666386f019a6e4103c3ef /read-cache.c | |
parent | tempfile: do not delete tempfile on failed close (diff) | |
download | tgif-83a3069a3895de81fea720ffa6a3e47f9400fe04.tar.xz |
lockfile: do not rollback lock on failed close
Since the lockfile code is based on the tempfile code, it
has some of the same problems, including that close_lock_file()
erases the tempfile's filename buf, making it hard for the
caller to write a good error message.
In practice this comes up less for lockfiles than for
straight tempfiles, since we usually just report the
refname. But there is at least one buggy case in
write_ref_to_lockfile(). Besides, given the coupling between
the lockfile and tempfile modules, it's less confusing if
their close() functions have the same semantics.
Just as the previous commit did for close_tempfile(), let's
teach close_lock_file() and its wrapper close_ref() not to
rollback on error. And just as before, we'll give them new
"gently" names to catch any new callers that are added.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c index 51686518e0..c3be65f8b0 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2345,7 +2345,7 @@ static int do_write_locked_index(struct index_state *istate, struct lock_file *l if (flags & COMMIT_LOCK) return commit_locked_index(lock); else if (flags & CLOSE_LOCK) - return close_lock_file(lock); + return close_lock_file_gently(lock); else return ret; } |