Files
git/builtin
Martin Ågren 0fa5a2ed8d lock_file: move static locks into functions
Placing `struct lock_file`s on the stack used to be a bad idea, because
the temp- and lockfile-machinery would keep a pointer into the struct.
But after 076aa2cbd (tempfile: auto-allocate tempfiles on heap,
2017-09-05), we can safely have lockfiles on the stack. (This applies
even if a user returns early, leaving a locked lock behind.)

Each of these `struct lock_file`s is used from within a single function.
Move them into the respective functions to make the scope clearer and
drop the staticness.

For good measure, I have inspected these sites and come to believe that
they always release the lock, with the possible exception of bailing out
using `die()` or `exit()` or by returning from a `cmd_foo()`.

As pointed out by Jeff King, it would be bad if someone held on to a
`struct lock_file *` for some reason. After some grepping, I agree with
his findings: no-one appears to be doing that.

After this commit, the remaining occurrences of "static struct
lock_file" are locks that are used from within different functions. That
is, they need to remain static. (Short of more intrusive changes like
passing around pointers to non-static locks.)

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-05-10 14:55:40 +09:00
..
2017-10-06 10:07:18 +09:00
2018-02-07 12:41:36 -08:00
2018-03-06 14:54:07 -08:00
2017-10-07 16:27:55 +09:00
2018-03-14 12:01:07 -07:00
2018-03-06 14:54:07 -08:00
2018-03-14 12:01:07 -07:00
2018-02-22 10:08:05 -08:00
2018-02-22 10:08:05 -08:00
2017-11-21 14:07:50 +09:00
2017-06-24 14:28:41 -07:00
2018-03-06 14:54:07 -08:00
2018-03-14 12:01:07 -07:00
2017-08-26 22:55:09 -07:00
2018-03-06 14:54:07 -08:00
2018-03-14 12:01:07 -07:00
2018-03-14 12:01:07 -07:00
2017-12-08 09:52:42 -08:00
2018-03-06 14:54:07 -08:00
2017-12-13 11:15:14 -08:00
2017-08-22 10:29:03 -07:00
2017-12-27 11:16:29 -08:00
2018-03-14 12:01:07 -07:00
2017-11-21 14:07:50 +09:00