diff options
author | Martin Ågren <martin.agren@gmail.com> | 2017-10-05 22:32:03 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-06 03:07:10 +0200 |
commit | f132a127eebb8f1b14b87fc317ca68278fceb2e8 (patch) | |
tree | e5da266e43348b450313a6679f790623436cffdc /builtin/am.c | |
parent | The eleventh batch for 2.15 (diff) | |
download | git-f132a127eebb8f1b14b87fc317ca68278fceb2e8.tar.xz git-f132a127eebb8f1b14b87fc317ca68278fceb2e8.zip |
sha1_file: do not leak `lock_file`
There is no longer any need to allocate and leak a `struct lock_file`.
Initialize it on the stack instead.
Before this patch, we set `lock = NULL` to signal that we have already
rolled back, and that we should not do any more work. We need to take
another approach now that we cannot assign NULL. We could, e.g., use
`is_lock_file_locked()`. But we already have another variable that we
could use instead, `found`. Its scope is only too small.
Bump `found` to the scope of the whole function and rearrange the "roll
back or write?"-checks to a straightforward if-else on `found`. This
also future-proves the code by making it obvious that we intend to take
exactly one of these paths.
Improved-by: Jeff King <peff@peff.net>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
0 files changed, 0 insertions, 0 deletions