summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-30 05:04:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-30 05:04:05 (GMT)
commit2f76ebc93ca6bfc2aba1be330aabe391a7d093d2 (patch)
tree2aba711da4a334aeaa374345e1714973d1e92315 /t/helper
parent0e7af5f6d16a4cef7d981ac9631f35d146904eca (diff)
parent0fa5a2ed8d9f6d987f1ea479fe8ea56a26b89303 (diff)
downloadgit-2f76ebc93ca6bfc2aba1be330aabe391a7d093d2.zip
git-2f76ebc93ca6bfc2aba1be330aabe391a7d093d2.tar.gz
git-2f76ebc93ca6bfc2aba1be330aabe391a7d093d2.tar.bz2
Merge branch 'ma/lockfile-cleanup'
Code clean-up to adjust to a more recent lockfile API convention that allows lockfile instances kept on the stack. * ma/lockfile-cleanup: lock_file: move static locks into functions lock_file: make function-local locks non-static refs.c: do not die if locking fails in `delete_pseudoref()` refs.c: do not die if locking fails in `write_pseudoref()` t/helper/test-write-cache: clean up lock-handling
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-scrap-cache-tree.c4
-rw-r--r--t/helper/test-write-cache.c14
2 files changed, 7 insertions, 11 deletions
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index d26d3e7..393f160 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -4,10 +4,10 @@
#include "tree.h"
#include "cache-tree.h"
-static struct lock_file index_lock;
-
int cmd__scrap_cache_tree(int ac, const char **av)
{
+ struct lock_file index_lock = LOCK_INIT;
+
setup_git_directory();
hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
if (read_cache() < 0)
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index 017dc30..8837717 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
@@ -2,22 +2,18 @@
#include "cache.h"
#include "lockfile.h"
-static struct lock_file index_lock;
-
int cmd__write_cache(int argc, const char **argv)
{
- int i, cnt = 1, lockfd;
+ struct lock_file index_lock = LOCK_INIT;
+ int i, cnt = 1;
if (argc == 2)
cnt = strtol(argv[1], NULL, 0);
setup_git_directory();
read_cache();
for (i = 0; i < cnt; i++) {
- lockfd = hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
- if (0 <= lockfd) {
- write_locked_index(&the_index, &index_lock, COMMIT_LOCK);
- } else {
- rollback_lock_file(&index_lock);
- }
+ hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
+ if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
+ die("unable to write index file");
}
return 0;