2018-03-24 10:45:05 +03:00
|
|
|
#include "test-tool.h"
|
2017-08-22 00:24:30 +03:00
|
|
|
#include "cache.h"
|
|
|
|
#include "lockfile.h"
|
|
|
|
|
2018-03-24 10:45:05 +03:00
|
|
|
int cmd__write_cache(int argc, const char **argv)
|
2017-08-22 00:24:30 +03:00
|
|
|
{
|
2018-05-09 23:55:35 +03:00
|
|
|
struct lock_file index_lock = LOCK_INIT;
|
|
|
|
int i, cnt = 1;
|
2017-08-22 00:24:30 +03:00
|
|
|
if (argc == 2)
|
|
|
|
cnt = strtol(argv[1], NULL, 0);
|
|
|
|
setup_git_directory();
|
|
|
|
read_cache();
|
|
|
|
for (i = 0; i < cnt; i++) {
|
2018-05-09 23:55:35 +03:00
|
|
|
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");
|
2017-08-22 00:24:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|