path: root/builtin/diff.c
diff options
authorMartin Ågren <>2017-10-05 20:32:03 (GMT)
committerJunio C Hamano <>2017-10-06 01:07:10 (GMT)
commitf132a127eebb8f1b14b87fc317ca68278fceb2e8 (patch)
treee5da266e43348b450313a6679f790623436cffdc /builtin/diff.c
parentea220ee40cbb03a63ebad2be902057bf742492fd (diff)
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 <> Signed-off-by: Martin Ågren <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/diff.c')
0 files changed, 0 insertions, 0 deletions