2022-11-19 13:07:37 +00:00
|
|
|
#define USE_THE_INDEX_VARIABLE
|
2018-03-24 07:45:05 +00:00
|
|
|
#include "test-tool.h"
|
2017-08-21 21:24:30 +00:00
|
|
|
#include "lockfile.h"
|
2023-05-16 06:33:56 +00:00
|
|
|
#include "read-cache-ll.h"
|
2023-04-22 20:17:20 +00:00
|
|
|
#include "repository.h"
|
2023-03-21 06:26:05 +00:00
|
|
|
#include "setup.h"
|
2017-08-21 21:24:30 +00:00
|
|
|
|
2018-03-24 07:45:05 +00:00
|
|
|
int cmd__write_cache(int argc, const char **argv)
|
2017-08-21 21:24:30 +00:00
|
|
|
{
|
2018-05-09 20:55:35 +00:00
|
|
|
struct lock_file index_lock = LOCK_INIT;
|
|
|
|
int i, cnt = 1;
|
2017-08-21 21:24:30 +00:00
|
|
|
if (argc == 2)
|
|
|
|
cnt = strtol(argv[1], NULL, 0);
|
|
|
|
setup_git_directory();
|
2022-11-19 13:07:35 +00:00
|
|
|
repo_read_index(the_repository);
|
2017-08-21 21:24:30 +00:00
|
|
|
for (i = 0; i < cnt; i++) {
|
2022-11-19 13:07:35 +00:00
|
|
|
repo_hold_locked_index(the_repository, &index_lock,
|
|
|
|
LOCK_DIE_ON_ERROR);
|
2018-05-09 20:55:35 +00:00
|
|
|
if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
|
|
|
|
die("unable to write index file");
|
2017-08-21 21:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|