aboutsummaryrefslogtreecommitdiffstats
path: root/t/helper/test-write-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-30 14:04:05 +0900
committerJunio C Hamano <gitster@pobox.com>2018-05-30 14:04:05 +0900
commit2f76ebc93ca6bfc2aba1be330aabe391a7d093d2 (patch)
tree2aba711da4a334aeaa374345e1714973d1e92315 /t/helper/test-write-cache.c
parentMerge branch 'sg/t6500-no-redirect-of-stdin' (diff)
parentlock_file: move static locks into functions (diff)
downloadgit-2f76ebc93ca6bfc2aba1be330aabe391a7d093d2.tar.gz
git-2f76ebc93ca6bfc2aba1be330aabe391a7d093d2.zip
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/test-write-cache.c')
-rw-r--r--t/helper/test-write-cache.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index 017dc30380..8837717d36 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;
>2021-03-30builtin/multi-pack-index.c: define common usage with a macroTaylor Blau1-1/+16 2021-03-30builtin/multi-pack-index.c: don't handle 'progress' separatelyTaylor Blau1-5/+3 2021-03-30builtin/multi-pack-index.c: inline 'flags' with optionsTaylor Blau1-7/+6 2021-03-29column, range-diff: downcase option descriptionChinmoy Chakraborty2-5/+5 2021-03-29cmake(install): include vcpkg dllsDennis Ameling2-0/+9 2021-03-29cmake: add a preparatory work-around to accommodate `vcpkg`Johannes Schindelin1-5/+9 2021-03-28fetch-pack: use new fsck API to printing dangling submodulesÆvar Arnfjörð Bjarmason4-51/+39 2021-03-28fetch-pack: use file-scope static struct for fsck_optionsÆvar Arnfjörð Bjarmason1-3/+3 2021-03-28fetch-pack: don't needlessly copy fsck_optionsÆvar Arnfjörð Bjarmason1-7/+3 2021-03-28fsck.c: move gitmodules_{found,done} into fsck_optionsÆvar Arnfjörð Bjarmason3-15/+19 2021-03-28fsck.c: add an fsck_set_msg_type() API that takes enumsÆvar Arnfjörð Bjarmason3-11/+22 2021-03-28fsck.c: pass along the fsck_msg_id in the fsck_error callbackÆvar Arnfjörð Bjarmason5-6/+14 2021-03-28fsck.[ch]: move FOREACH_FSCK_MSG_ID & fsck_msg_id from *.c to *.hÆvar Arnfjörð Bjarmason2-66/+66 2021-03-28fsck.c: give "FOREACH_MSG_ID" a more specific nameÆvar Arnfjörð Bjarmason1-3/+3 2021-03-28fsck.c: undefine temporary STR macro after useÆvar Arnfjörð Bjarmason1-0/+1 2021-03-28fsck.c: call parse_msg_type() early in fsck_set_msg_type()Ævar Arnfjörð Bjarmason1-2/+1 2021-03-28fsck.h: re-order and re-assign "enum fsck_msg_type"Ævar Arnfjörð Bjarmason1-4/+6 2021-03-28fsck.h: move FSCK_{FATAL,INFO,ERROR,WARN,IGNORE} into an enumÆvar Arnfjörð Bjarmason5-20/+25 2021-03-28fsck.c: refactor fsck_msg_type() to limit scope of "int msg_type"Ævar Arnfjörð Bjarmason1-7/+5 2021-03-28fsck.c: rename remaining fsck_msg_id "id" to "msg_id"Ævar Arnfjörð Bjarmason1-3/+3 2021-03-28fsck.c: remove (mostly) redundant append_msg_id() functionÆvar Arnfjörð Bjarmason1-19/+2 2021-03-28fsck.c: rename variables in fsck_set_msg_type() for less confusionÆvar Arnfjörð Bjarmason2-13/+13 2021-03-28fsck.h: use "enum object_type" instead of "int"Ævar Arnfjörð Bjarmason4-4/+8 2021-03-28fsck.h: use designed initializers for FSCK_OPTIONS_{DEFAULT,STRICT}Ævar Arnfjörð Bjarmason1-2/+8 2021-03-27cmake(install): fix double .exe suffixesDennis Ameling1-2/+2 2021-03-27cmake: support SKIP_DASHED_BUILT_INSJohannes Schindelin1-0/+4 2021-03-27Document how we do embargoed releasesJohannes Schindelin2-0/+132