summaryrefslogtreecommitdiff
path: root/builtin/diff.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-10-05 20:32:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-06 01:07:10 (GMT)
commitf132a127eebb8f1b14b87fc317ca68278fceb2e8 (patch)
treee5da266e43348b450313a6679f790623436cffdc /builtin/diff.c
parentea220ee40cbb03a63ebad2be902057bf742492fd (diff)
downloadgit-f132a127eebb8f1b14b87fc317ca68278fceb2e8.zip
git-f132a127eebb8f1b14b87fc317ca68278fceb2e8.tar.gz
git-f132a127eebb8f1b14b87fc317ca68278fceb2e8.tar.bz2
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/diff.c')
0 files changed, 0 insertions, 0 deletions