diff options
| author | Junio C Hamano <gitster@pobox.com> | 2018-05-30 14:04:05 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2018-05-30 14:04:05 +0900 |
| commit | 2f76ebc93ca6bfc2aba1be330aabe391a7d093d2 (patch) | |
| tree | 2aba711da4a334aeaa374345e1714973d1e92315 /t/helper/test-write-cache.c | |
| parent | 0e7af5f6d16a4cef7d981ac9631f35d146904eca (diff) | |
| parent | 0fa5a2ed8d9f6d987f1ea479fe8ea56a26b89303 (diff) | |
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.c | 14 |
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; |
