t/helper/test-write-cache: clean up lock-handling
[git] / t / helper / test-write-cache.c
1 #include "cache.h"
2 #include "lockfile.h"
3
4 int cmd_main(int argc, const char **argv)
5 {
6         struct lock_file index_lock = LOCK_INIT;
7         int i, cnt = 1;
8         if (argc == 2)
9                 cnt = strtol(argv[1], NULL, 0);
10         setup_git_directory();
11         read_cache();
12         for (i = 0; i < cnt; i++) {
13                 hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
14                 if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
15                         die("unable to write index file");
16         }
17
18         return 0;
19 }