summaryrefslogtreecommitdiff
path: root/branch.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-10-05 20:32:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-06 01:07:18 (GMT)
commit02ae242fdde2ba8acb6b87e32df2b1e33786e78b (patch)
treef251cfa7b4c15c5fa52cc713d15299578235d58b /branch.c
parent5de134ca8594de22f2a0b738824f9b5176ae6c00 (diff)
downloadgit-02ae242fdde2ba8acb6b87e32df2b1e33786e78b.zip
git-02ae242fdde2ba8acb6b87e32df2b1e33786e78b.tar.gz
git-02ae242fdde2ba8acb6b87e32df2b1e33786e78b.tar.bz2
checkout-index: simplify locking logic
`newfd` starts out negative. If we then take the lock, `newfd` will become non-negative. We later check for exactly that property before calling `write_locked_index()`. That is, we are simply using `newfd` as a boolean to keep track of whether we took the lock or not. (We always use `newfd` and `lock_file` together, so they really are mirroring each other.) Drop `newfd` and check with `is_lock_file_locked()` instead. While at it, move the `static struct lock_file` into `cmd_checkout_index()` and make it non-static. It is only used in this function, and after 076aa2cbd (tempfile: auto-allocate tempfiles on heap, 2017-09-05), we can have lockfiles on the stack. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'branch.c')
0 files changed, 0 insertions, 0 deletions