t / helper / test-write-cache.con commit t/helper: merge test-config into test-tool (0e2678a)
   1#include "cache.h"
   2#include "lockfile.h"
   3
   4static struct lock_file index_lock;
   5
   6int cmd_main(int argc, const char **argv)
   7{
   8        int i, cnt = 1, lockfd;
   9        if (argc == 2)
  10                cnt = strtol(argv[1], NULL, 0);
  11        setup_git_directory();
  12        read_cache();
  13        for (i = 0; i < cnt; i++) {
  14                lockfd = hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
  15                if (0 <= lockfd) {
  16                        write_locked_index(&the_index, &index_lock, COMMIT_LOCK);
  17                } else {
  18                        rollback_lock_file(&index_lock);
  19                }
  20        }
  21
  22        return 0;
  23}