git-commit-vandalism/t/helper
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
..
.gitignore Merge branch 'sb/test-helper-excludes' 2017-12-27 11:16:29 -08:00
test-chmtime.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-config.c config: don't include config.h by default 2017-06-15 12:56:22 -07:00
test-ctype.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-date.c config: add --expiry-date 2017-11-18 12:31:29 +09:00
test-delta.c avoid "write_in_full(fd, buf, len) != len" pattern 2017-09-14 15:17:59 +09:00
test-drop-caches.c fsmonitor: add a performance test 2017-10-01 17:23:05 +09:00
test-dump-cache-tree.c Convert struct cache_tree to use struct object_id 2017-05-02 10:46:41 +09:00
test-dump-fsmonitor.c fsmonitor: add a test tool to dump the index extension 2017-10-01 17:23:05 +09:00
test-dump-split-index.c cache: convert struct cache_entry to use struct object_id 2016-09-07 12:59:42 -07:00
test-dump-untracked-cache.c dir: convert struct sha1_stat to use object_id 2018-01-30 10:42:36 -08:00
test-example-decorate.c decorate: clean up and document API 2017-12-08 09:16:27 -08:00
test-fake-ssh.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-genrandom.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-hashmap.c test-hashmap: use "unsigned int" for hash storage 2018-02-14 10:31:10 -08:00
test-index-version.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-lazy-init-name-hash.c t/helper/test-lazy-name-hash: fix compilation 2017-12-22 10:42:04 -08:00
test-line-buffer.c test-line-buffer: simplify command parsing 2017-09-22 12:49:53 +09:00
test-match-trees.c tree: convert parse_tree_indirect to struct object_id 2017-05-08 15:12:58 +09:00
test-mergesort.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-mktemp.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-online-cpus.c test-online-cpus: helper to return cpu count 2017-04-12 23:17:19 -07:00
test-parse-options.c t0040,t1502: Demonstrate parse_options bugs 2017-09-25 14:35:50 +09:00
test-path-utils.c test-path-utils: handle const parameter of basename and dirname 2017-08-07 10:50:08 -07:00
test-prio-queue.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-read-cache.c test-read-cache: setup git dir 2017-04-16 20:05:11 -07:00
test-ref-store.c Merge branch 'bc/object-id' 2017-11-06 14:24:27 +09:00
test-regex.c
test-revision-walking.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-run-command.c run-command.c: print env vars in trace_run_command() 2018-01-19 10:49:20 -08:00
test-scrap-cache-tree.c lock_file: move static locks into functions 2018-05-10 14:55:40 +09:00
test-sha1-array.c Rename sha1_array to oid_array 2017-03-31 08:33:56 -07:00
test-sha1.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-sha1.sh test helpers: move test-* to t/helper/ subdirectory 2016-04-15 10:12:19 -07:00
test-sigchain.c
test-strcmp-offset.c Spelling fixes 2017-06-27 10:35:49 -07:00
test-string-list.c test-stringlist: avoid buffer underrun when sorting nothing 2017-10-04 13:41:49 +09:00
test-submodule-config.c submodule: remove gitmodules_config 2017-08-03 13:11:02 -07:00
test-subprocess.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-svn-fe.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-urlmatch-normalization.c Merge branch 'jk/common-main-2.8' into jk/common-main 2016-07-06 10:02:57 -07:00
test-wildmatch.c wildmatch test: perform all tests under all wildmatch() modes 2018-01-30 14:04:01 -08:00
test-write-cache.c t/helper/test-write-cache: clean up lock-handling 2018-05-10 14:54:44 +09:00