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