t / helper / test-write-cache.con commit t/helper/test-write-cache: clean up lock-handling (75d9a25)
   1#include "cache.h"
   2#include "lockfile.h"
   3
   4int 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}