]> git.ipfire.org Git - thirdparty/git.git/blame - t/helper/test-write-cache.c
Merge branch 'jc/unleak-core-excludesfile'
[thirdparty/git.git] / t / helper / test-write-cache.c
CommitLineData
bdafeae0 1#define USE_THE_INDEX_VARIABLE
c81f843d 2#include "test-tool.h"
3921a0b3 3#include "lockfile.h"
08c46a49 4#include "read-cache-ll.h"
d1cbe1e6 5#include "repository.h"
e38da487 6#include "setup.h"
3921a0b3 7
c81f843d 8int cmd__write_cache(int argc, const char **argv)
3921a0b3 9{
75d9a25e
10 struct lock_file index_lock = LOCK_INIT;
11 int i, cnt = 1;
3921a0b3
KW
12 if (argc == 2)
13 cnt = strtol(argv[1], NULL, 0);
14 setup_git_directory();
0ea414a1 15 repo_read_index(the_repository);
3921a0b3 16 for (i = 0; i < cnt; i++) {
0ea414a1
ÆAB
17 repo_hold_locked_index(the_repository, &index_lock,
18 LOCK_DIE_ON_ERROR);
75d9a25e
19 if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
20 die("unable to write index file");
3921a0b3
KW
21 }
22
23 return 0;
24}