sequencer: make lockfiles non-static

After 076aa2cbd (tempfile: auto-allocate tempfiles on heap, 2017-09-05), we can have lockfiles on the stack. One of these functions fails to always roll back the lock. That will be fixed in the next commit. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Feb 27, 2018 at 22:30 UTC 14bca6c63cec3bd6e9b636fd1ff5b0ea2bd5edce
1 file changed +5 -5
sequencer.c
+5 -5
@@ -339,7 +339,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)
339 static int write_message(const void *buf, size_t len, const char *filename,
340 int append_eol)
341 {
342 - static struct lock_file msg_file;
342 + struct lock_file msg_file = LOCK_INIT;
343
344 int msg_fd = hold_lock_file_for_update(&msg_file, filename, 0);
345 if (msg_fd < 0)
@@ -485,7 +485,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
485 struct tree *result, *next_tree, *base_tree, *head_tree;
486 int clean;
487 char **xopt;
488 - static struct lock_file index_lock;
488 + struct lock_file index_lock = LOCK_INIT;
489
490 if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0)
491 return -1;
@@ -1705,7 +1705,7 @@ static int prepare_revs(struct replay_opts *opts)
1705
1706 static int read_and_refresh_cache(struct replay_opts *opts)
1707 {
1708 - static struct lock_file index_lock;
1708 + struct lock_file index_lock = LOCK_INIT;
1709 int index_fd = hold_locked_index(&index_lock, 0);
1710 if (read_index_preload(&the_index, NULL) < 0) {
1711 rollback_lock_file(&index_lock);
@@ -2099,7 +2099,7 @@ static int create_seq_dir(void)
2099
2100 static int save_head(const char *head)
2101 {
2102 - static struct lock_file head_lock;
2102 + struct lock_file head_lock = LOCK_INIT;
2103 struct strbuf buf = STRBUF_INIT;
2104 int fd;
2105 ssize_t written;
@@ -2224,7 +2224,7 @@ fail:
2224
2225 static int save_todo(struct todo_list *todo_list, struct replay_opts *opts)
2226 {
2227 - static struct lock_file todo_lock;
2227 + struct lock_file todo_lock = LOCK_INIT;
2228 const char *todo_path = get_todo_path(opts);
2229 int next = todo_list->current, offset, fd;
2230