blob: d2a63bea4346fb76d38ba43508ee6e60599e41a9 [file] [log] [blame]
Thomas Rast1aed2fe2011-12-06 18:43:35 +01001#include "cache.h"
Michael Haggerty697cc8e2014-10-01 12:28:42 +02002#include "lockfile.h"
Thomas Rast1aed2fe2011-12-06 18:43:35 +01003#include "tree.h"
4#include "cache-tree.h"
5
6static struct lock_file index_lock;
7
Jeff King3f2e2292016-07-01 01:58:58 -04008int cmd_main(int ac, const char **av)
Thomas Rast1aed2fe2011-12-06 18:43:35 +01009{
Jeff King4ce742f2016-10-20 02:16:59 -040010 setup_git_directory();
Junio C Hamanob3e83cc2016-12-07 10:33:54 -080011 hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
Thomas Rast1aed2fe2011-12-06 18:43:35 +010012 if (read_cache() < 0)
13 die("unable to read index file");
14 active_cache_tree = NULL;
Nguyễn Thái Ngọc Duy03b86642014-06-13 19:19:23 +070015 if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
Thomas Rast1aed2fe2011-12-06 18:43:35 +010016 die("unable to write index file");
17 return 0;
18}