aboutsummaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-10-05 22:32:08 +0200
committerJunio C Hamano <gitster@pobox.com>2017-10-06 10:07:18 +0900
commit2954e5ec4361c6932593663859aa437583edb500 (patch)
tree0227b2bd8e5cb3485574b72377ceaa430048c684 /apply.c
parent02ae242fdde2ba8acb6b87e32df2b1e33786e78b (diff)
downloadgit-2954e5ec4361c6932593663859aa437583edb500.tar.gz
git-2954e5ec4361c6932593663859aa437583edb500.tar.xz
cache-tree: simplify locking logic
After we have taken the lock using `LOCK_DIE_ON_ERROR`, we know that `newfd` is non-negative. So when we check for exactly that property before calling `write_locked_index()`, the outcome is guaranteed. If we write and commit successfully, we set `newfd = -1`, so that we can later avoid calling `rollback_lock_file` on an already-committed lock. But we might just as well unconditionally call `rollback_lock_file()` -- it will be a no-op if we have already committed. All in all, we use `newfd` as a bool and the only benefit we get from it is that we can avoid calling a no-op. Remove `newfd` so that we have one variable less to reason about. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.c')
0 files changed, 0 insertions, 0 deletions