blob: 2e086a204dc7b19271cdeb2733c62a64066ab304 [file] [log] [blame]
Linus Torvalds33db5f42005-04-09 09:53:05 -07001/*
2 * Check-out files from the "current cache directory"
3 *
4 * Copyright (C) 2005 Linus Torvalds
5 *
Linus Torvalds33db5f42005-04-09 09:53:05 -07006 */
Ævar Arnfjörð Bjarmason07047d62022-11-19 14:07:38 +01007#define USE_THE_INDEX_VARIABLE
Peter Hagervallbaffc0e2007-07-15 01:14:45 +02008#include "builtin.h"
Brandon Williamsb2141fc2017-06-14 11:07:36 -07009#include "config.h"
Elijah Newrenf394e092023-03-21 06:25:54 +000010#include "gettext.h"
Michael Haggerty697cc8e2014-10-01 12:28:42 +020011#include "lockfile.h"
Shawn Pearce9debe632006-02-28 21:43:33 -050012#include "quote.h"
Elijah Newrend1cbe1e2023-04-22 20:17:20 +000013#include "repository.h"
Junio C Hamanobad68ec2006-04-24 21:18:58 -070014#include "cache-tree.h"
Miklos Vajnaa6c7db12008-10-18 03:17:23 +020015#include "parse-options.h"
Matheus Tavaresd052cc02021-03-23 11:19:32 -030016#include "entry.h"
Matheus Tavares70b052b2021-05-04 13:27:30 -030017#include "parallel-checkout.h"
Elijah Newren08c46a42023-05-16 06:33:56 +000018#include "read-cache-ll.h"
Elijah Newrene38da482023-03-21 06:26:05 +000019#include "setup.h"
Elijah Newrenbaf889c2023-05-16 06:33:51 +000020#include "sparse-index.h"
Linus Torvalds33db5f42005-04-09 09:53:05 -070021
Shawn Pearcede84f992006-03-05 03:24:15 -050022#define CHECKOUT_ALL 4
Junio C Hamanoa392f572016-01-13 16:14:48 -080023static int nul_term_line;
Junio C Hamano3bd348a2005-12-07 00:29:51 -080024static int checkout_stage; /* default to checkout stage0 */
Victoria Dye88078f52022-01-11 18:05:02 +000025static int ignore_skip_worktree; /* default to 0 */
Jeff King9b403862023-09-05 03:12:59 -040026static int to_tempfile = -1;
Junio C Hamanoaf2a6512013-10-23 10:52:42 -070027static char topath[4][TEMPORARY_FILENAME_LENGTH + 1];
Junio C Hamanoc3e9a652005-11-26 00:22:48 -080028
René Scharfe68e3d622016-09-22 18:11:33 +020029static struct checkout state = CHECKOUT_INIT;
Linus Torvalds33db5f42005-04-09 09:53:05 -070030
Eric Sunshine74c4de52014-12-24 04:43:16 -050031static void write_tempfile_record(const char *name, const char *prefix)
Shawn Pearcede84f992006-03-05 03:24:15 -050032{
33 int i;
Matheus Tavares3f7ba602021-02-16 11:06:52 -030034 int have_tempname = 0;
Shawn Pearcede84f992006-03-05 03:24:15 -050035
36 if (CHECKOUT_ALL == checkout_stage) {
Matheus Tavares3f7ba602021-02-16 11:06:52 -030037 for (i = 1; i < 4; i++)
38 if (topath[i][0]) {
39 have_tempname = 1;
40 break;
41 }
Shawn Pearcede84f992006-03-05 03:24:15 -050042
Matheus Tavares3f7ba602021-02-16 11:06:52 -030043 if (have_tempname) {
44 for (i = 1; i < 4; i++) {
45 if (i > 1)
46 putchar(' ');
47 if (topath[i][0])
48 fputs(topath[i], stdout);
49 else
50 putchar('.');
51 }
52 }
53 } else if (topath[checkout_stage][0]) {
54 have_tempname = 1;
55 fputs(topath[checkout_stage], stdout);
56 }
57
58 if (have_tempname) {
59 putchar('\t');
60 write_name_quoted_relative(name, prefix, stdout,
61 nul_term_line ? '\0' : '\n');
62 }
Shawn Pearcede84f992006-03-05 03:24:15 -050063
64 for (i = 0; i < 4; i++) {
65 topath[i][0] = 0;
66 }
67}
68
Eric Sunshine74c4de52014-12-24 04:43:16 -050069static int checkout_file(const char *name, const char *prefix)
Linus Torvalds33db5f42005-04-09 09:53:05 -070070{
Junio C Hamano3bd348a2005-12-07 00:29:51 -080071 int namelen = strlen(name);
Ævar Arnfjörð Bjarmason07047d62022-11-19 14:07:38 +010072 int pos = index_name_pos(&the_index, name, namelen);
Junio C Hamano3bd348a2005-12-07 00:29:51 -080073 int has_same_name = 0;
Victoria Dye35682ad2022-01-11 18:05:03 +000074 int is_file = 0;
Victoria Dye88078f52022-01-11 18:05:02 +000075 int is_skipped = 1;
Shawn Pearcede84f992006-03-05 03:24:15 -050076 int did_checkout = 0;
77 int errs = 0;
Junio C Hamano3bd348a2005-12-07 00:29:51 -080078
79 if (pos < 0)
80 pos = -pos - 1;
81
Ævar Arnfjörð Bjarmasondc594182022-11-19 14:07:34 +010082 while (pos < the_index.cache_nr) {
83 struct cache_entry *ce = the_index.cache[pos];
Junio C Hamanof4f9ada2005-12-13 21:39:56 -080084 if (ce_namelen(ce) != namelen ||
Junio C Hamano3bd348a2005-12-07 00:29:51 -080085 memcmp(ce->name, name, namelen))
86 break;
87 has_same_name = 1;
Junio C Hamano3bd348a2005-12-07 00:29:51 -080088 pos++;
Victoria Dye35682ad2022-01-11 18:05:03 +000089 if (S_ISSPARSEDIR(ce->ce_mode))
90 break;
91 is_file = 1;
Victoria Dye88078f52022-01-11 18:05:02 +000092 if (!ignore_skip_worktree && ce_skip_worktree(ce))
93 break;
94 is_skipped = 0;
Shawn Pearcede84f992006-03-05 03:24:15 -050095 if (ce_stage(ce) != checkout_stage
96 && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce)))
97 continue;
98 did_checkout = 1;
99 if (checkout_entry(ce, &state,
Nguyễn Thái Ngọc Duy0f086e62018-11-13 19:28:00 +0100100 to_tempfile ? topath[ce_stage(ce)] : NULL,
101 NULL) < 0)
Shawn Pearcede84f992006-03-05 03:24:15 -0500102 errs++;
103 }
104
105 if (did_checkout) {
106 if (to_tempfile)
Eric Sunshine74c4de52014-12-24 04:43:16 -0500107 write_tempfile_record(name, prefix);
Shawn Pearcede84f992006-03-05 03:24:15 -0500108 return errs > 0 ? -1 : 0;
Linus Torvalds33db5f42005-04-09 09:53:05 -0700109 }
Junio C Hamano3bd348a2005-12-07 00:29:51 -0800110
Jeff King0b809c82020-10-27 03:36:02 -0400111 /*
112 * At this point we know we didn't try to check anything out. If it was
113 * because we did find an entry but it was stage 0, that's not an
114 * error.
115 */
116 if (has_same_name && checkout_stage == CHECKOUT_ALL)
117 return 0;
118
Junio C Hamano3bd348a2005-12-07 00:29:51 -0800119 if (!state.quiet) {
Heikki Orsila05207a22008-09-09 13:28:30 +0300120 fprintf(stderr, "git checkout-index: %s ", name);
Junio C Hamano3bd348a2005-12-07 00:29:51 -0800121 if (!has_same_name)
122 fprintf(stderr, "is not in the cache");
Victoria Dye35682ad2022-01-11 18:05:03 +0000123 else if (!is_file)
124 fprintf(stderr, "is a sparse directory");
Victoria Dye88078f52022-01-11 18:05:02 +0000125 else if (is_skipped)
126 fprintf(stderr, "has skip-worktree enabled; "
127 "use '--ignore-skip-worktree-bits' to checkout");
Junio C Hamano3bd348a2005-12-07 00:29:51 -0800128 else if (checkout_stage)
129 fprintf(stderr, "does not exist at stage %d",
130 checkout_stage);
131 else
132 fprintf(stderr, "is unmerged");
133 fputc('\n', stderr);
134 }
135 return -1;
Linus Torvalds33db5f42005-04-09 09:53:05 -0700136}
137
Matheus Tavares70b052b2021-05-04 13:27:30 -0300138static int checkout_all(const char *prefix, int prefix_length)
Linus Torvalds33db5f42005-04-09 09:53:05 -0700139{
Junio C Hamano4b12dae2005-10-03 12:44:48 -0700140 int i, errs = 0;
Felipe Contreras4b25d092009-05-01 12:06:36 +0300141 struct cache_entry *last_ce = NULL;
Linus Torvalds33db5f42005-04-09 09:53:05 -0700142
Ævar Arnfjörð Bjarmasondc594182022-11-19 14:07:34 +0100143 for (i = 0; i < the_index.cache_nr ; i++) {
144 struct cache_entry *ce = the_index.cache[i];
Victoria Dye35682ad2022-01-11 18:05:03 +0000145
146 if (S_ISSPARSEDIR(ce->ce_mode)) {
147 if (!ce_skip_worktree(ce))
148 BUG("sparse directory '%s' does not have skip-worktree set", ce->name);
149
150 /*
151 * If the current entry is a sparse directory and skip-worktree
152 * entries are being checked out, expand the index and continue
153 * the loop on the current index position (now pointing to the
154 * first entry inside the expanded sparse directory).
155 */
156 if (ignore_skip_worktree) {
157 ensure_full_index(&the_index);
Ævar Arnfjörð Bjarmasondc594182022-11-19 14:07:34 +0100158 ce = the_index.cache[i];
Victoria Dye35682ad2022-01-11 18:05:03 +0000159 }
160 }
161
Victoria Dye88078f52022-01-11 18:05:02 +0000162 if (!ignore_skip_worktree && ce_skip_worktree(ce))
163 continue;
Shawn Pearcede84f992006-03-05 03:24:15 -0500164 if (ce_stage(ce) != checkout_stage
165 && (CHECKOUT_ALL != checkout_stage || !ce_stage(ce)))
Linus Torvaldsd9f98ee2005-04-17 18:39:14 -0700166 continue;
Junio C Hamanoc3e9a652005-11-26 00:22:48 -0800167 if (prefix && *prefix &&
Junio C Hamano3bd348a2005-12-07 00:29:51 -0800168 (ce_namelen(ce) <= prefix_length ||
169 memcmp(prefix, ce->name, prefix_length)))
Junio C Hamanoc3e9a652005-11-26 00:22:48 -0800170 continue;
Shawn Pearcede84f992006-03-05 03:24:15 -0500171 if (last_ce && to_tempfile) {
172 if (ce_namelen(last_ce) != ce_namelen(ce)
173 || memcmp(last_ce->name, ce->name, ce_namelen(ce)))
Eric Sunshine74c4de52014-12-24 04:43:16 -0500174 write_tempfile_record(last_ce->name, prefix);
Shawn Pearcede84f992006-03-05 03:24:15 -0500175 }
176 if (checkout_entry(ce, &state,
Nguyễn Thái Ngọc Duy0f086e62018-11-13 19:28:00 +0100177 to_tempfile ? topath[ce_stage(ce)] : NULL,
178 NULL) < 0)
Junio C Hamano4b12dae2005-10-03 12:44:48 -0700179 errs++;
Shawn Pearcede84f992006-03-05 03:24:15 -0500180 last_ce = ce;
Linus Torvalds33db5f42005-04-09 09:53:05 -0700181 }
Shawn Pearcede84f992006-03-05 03:24:15 -0500182 if (last_ce && to_tempfile)
Eric Sunshine74c4de52014-12-24 04:43:16 -0500183 write_tempfile_record(last_ce->name, prefix);
Matheus Tavares70b052b2021-05-04 13:27:30 -0300184 return !!errs;
Linus Torvalds33db5f42005-04-09 09:53:05 -0700185}
186
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200187static const char * const builtin_checkout_index_usage[] = {
Alex Henrie9c9b4f22015-01-13 00:44:47 -0700188 N_("git checkout-index [<options>] [--] [<file>...]"),
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200189 NULL
190};
Junio C Hamanod46ad9c2005-07-13 20:25:07 -0700191
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200192static int option_parse_stage(const struct option *opt,
193 const char *arg, int unset)
194{
Jeff King66e33092023-08-31 17:21:07 -0400195 int *stage = opt->value;
196
Jeff King517fe802018-11-05 01:45:42 -0500197 BUG_ON_OPT_NEG(unset);
198
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200199 if (!strcmp(arg, "all")) {
Jeff King66e33092023-08-31 17:21:07 -0400200 *stage = CHECKOUT_ALL;
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200201 } else {
202 int ch = arg[0];
203 if ('1' <= ch && ch <= '3')
Jeff King66e33092023-08-31 17:21:07 -0400204 *stage = arg[0] - '0';
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200205 else
Jeff King22396172016-01-31 22:18:24 -0500206 die(_("stage should be between 1 and 3 or all"));
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200207 }
208 return 0;
209}
210
Junio C Hamanoe4141562006-08-04 01:23:19 -0700211int cmd_checkout_index(int argc, const char **argv, const char *prefix)
Linus Torvalds33db5f42005-04-09 09:53:05 -0700212{
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700213 int i;
Martin Ågren02ae2422017-10-05 22:32:07 +0200214 struct lock_file lock_file = LOCK_INIT;
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700215 int all = 0;
Shawn Pearce9debe632006-02-28 21:43:33 -0500216 int read_from_stdin = 0;
Junio C Hamanoe4141562006-08-04 01:23:19 -0700217 int prefix_length;
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200218 int force = 0, quiet = 0, not_new = 0;
Jeff King6a6df8a2016-01-31 06:29:36 -0500219 int index_opt = 0;
Jeff King7e410612020-10-27 03:37:14 -0400220 int err = 0;
Matheus Tavares70b052b2021-05-04 13:27:30 -0300221 int pc_workers, pc_threshold;
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200222 struct option builtin_checkout_index_options[] = {
Stefan Bellerd5d09d42013-08-03 13:51:19 +0200223 OPT_BOOL('a', "all", &all,
Nguyễn Thái Ngọc Duyf63cf8c2012-08-20 19:32:55 +0700224 N_("check out all files in the index")),
Victoria Dye88078f52022-01-11 18:05:02 +0000225 OPT_BOOL(0, "ignore-skip-worktree-bits", &ignore_skip_worktree,
226 N_("do not skip files with skip-worktree set")),
Nguyễn Thái Ngọc Duy12247812018-02-09 18:01:42 +0700227 OPT__FORCE(&force, N_("force overwrite of existing files"), 0),
Jonathan Nieder8c839682010-11-08 13:54:48 -0600228 OPT__QUIET(&quiet,
Nguyễn Thái Ngọc Duy0ed21712012-08-20 19:31:58 +0700229 N_("no warning for existing files and files not in index")),
Stefan Beller5d4d1442013-08-03 13:51:25 +0200230 OPT_BOOL('n', "no-create", &not_new,
Nguyễn Thái Ngọc Duy0ed21712012-08-20 19:31:58 +0700231 N_("don't checkout new files")),
Jeff King6a6df8a2016-01-31 06:29:36 -0500232 OPT_BOOL('u', "index", &index_opt,
233 N_("update stat information in the index file")),
Jeff King9096ee12016-01-31 06:25:43 -0500234 OPT_BOOL('z', NULL, &nul_term_line,
235 N_("paths are separated with NUL character")),
Stefan Bellerd5d09d42013-08-03 13:51:19 +0200236 OPT_BOOL(0, "stdin", &read_from_stdin,
Nguyễn Thái Ngọc Duy0ed21712012-08-20 19:31:58 +0700237 N_("read list of paths from the standard input")),
Stefan Bellerd5d09d42013-08-03 13:51:19 +0200238 OPT_BOOL(0, "temp", &to_tempfile,
Nguyễn Thái Ngọc Duy0ed21712012-08-20 19:31:58 +0700239 N_("write the content to temporary files")),
Jeff King5ed5f672016-01-31 06:26:16 -0500240 OPT_STRING(0, "prefix", &state.base_dir, N_("string"),
241 N_("when creating files, prepend <string>")),
Jeff King66e33092023-08-31 17:21:07 -0400242 OPT_CALLBACK_F(0, "stage", &checkout_stage, "(1|2|3|all)",
Nguyễn Thái Ngọc Duy0ed21712012-08-20 19:31:58 +0700243 N_("copy out the files from named stage"),
Denton Liu203c8532020-04-28 04:36:28 -0400244 PARSE_OPT_NONEG, option_parse_stage),
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200245 OPT_END()
246 };
Linus Torvalds33db5f42005-04-09 09:53:05 -0700247
Nguyễn Thái Ngọc Duycf9d52e2010-10-22 01:44:01 -0500248 if (argc == 2 && !strcmp(argv[1], "-h"))
249 usage_with_options(builtin_checkout_index_usage,
250 builtin_checkout_index_options);
Johannes Schindelinef90d6d2008-05-14 18:46:53 +0100251 git_config(git_default_config, NULL);
Junio C Hamanoc3e9a652005-11-26 00:22:48 -0800252 prefix_length = prefix ? strlen(prefix) : 0;
253
Victoria Dye35682ad2022-01-11 18:05:03 +0000254 prepare_repo_settings(the_repository);
255 the_repository->settings.command_requires_full_index = 0;
256
Ævar Arnfjörð Bjarmason07047d62022-11-19 14:07:38 +0100257 if (repo_read_index(the_repository) < 0) {
Petr Baudis2de381f2005-04-13 02:28:48 -0700258 die("invalid cache");
Linus Torvalds33db5f42005-04-09 09:53:05 -0700259 }
260
Stephen Boyd37782922009-05-23 11:53:12 -0700261 argc = parse_options(argc, argv, prefix, builtin_checkout_index_options,
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200262 builtin_checkout_index_usage, 0);
Nguyễn Thái Ngọc Duy74cfc0e2018-08-13 18:14:32 +0200263 state.istate = &the_index;
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200264 state.force = force;
265 state.quiet = quiet;
266 state.not_new = not_new;
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700267
Jeff King5ed5f672016-01-31 06:26:16 -0500268 if (!state.base_dir)
269 state.base_dir = "";
270 state.base_dir_len = strlen(state.base_dir);
271
Jeff King9b403862023-09-05 03:12:59 -0400272 if (to_tempfile < 0)
273 to_tempfile = (checkout_stage == CHECKOUT_ALL);
274 if (!to_tempfile && checkout_stage == CHECKOUT_ALL)
275 die(_("options '%s' and '%s' cannot be used together"),
276 "--stage=all", "--no-temp");
277
Jeff King6a6df8a2016-01-31 06:29:36 -0500278 /*
279 * when --prefix is specified we do not want to update cache.
280 */
281 if (index_opt && !state.base_dir_len && !to_tempfile) {
282 state.refresh_cache = 1;
283 state.istate = &the_index;
Ævar Arnfjörð Bjarmason07047d62022-11-19 14:07:38 +0100284 repo_hold_locked_index(the_repository, &lock_file,
285 LOCK_DIE_ON_ERROR);
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700286 }
287
Matheus Tavares70b052b2021-05-04 13:27:30 -0300288 get_parallel_checkout_configs(&pc_workers, &pc_threshold);
289 if (pc_workers > 1)
290 init_parallel_checkout();
291
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700292 /* Check out named files first */
Miklos Vajnaa6c7db12008-10-18 03:17:23 +0200293 for (i = 0; i < argc; i++) {
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700294 const char *arg = argv[i];
Stefan Bellerd7a643b2015-05-04 12:11:54 -0700295 char *p;
Linus Torvaldsa65a6862005-10-17 17:32:12 -0700296
297 if (all)
Junio C Hamano7e44c932008-08-31 09:39:19 -0700298 die("git checkout-index: don't mix '--all' and explicit filenames");
Shawn Pearce9debe632006-02-28 21:43:33 -0500299 if (read_from_stdin)
Junio C Hamano7e44c932008-08-31 09:39:19 -0700300 die("git checkout-index: don't mix '--stdin' and explicit filenames");
Junio C Hamanodc46da22006-05-05 22:38:06 -0700301 p = prefix_path(prefix, prefix_length, arg);
Jeff King7e410612020-10-27 03:37:14 -0400302 err |= checkout_file(p, prefix);
Stefan Bellerd7a643b2015-05-04 12:11:54 -0700303 free(p);
Linus Torvalds33db5f42005-04-09 09:53:05 -0700304 }
Junio C Hamano415e96c2005-05-15 14:23:12 -0700305
Shawn Pearce9debe632006-02-28 21:43:33 -0500306 if (read_from_stdin) {
Jeff King0d4cc1b2016-01-31 06:25:26 -0500307 struct strbuf buf = STRBUF_INIT;
308 struct strbuf unquoted = STRBUF_INIT;
Junio C Hamanoa392f572016-01-13 16:14:48 -0800309 strbuf_getline_fn getline_fn;
Pierre Habouzit7fb10112007-09-20 00:42:14 +0200310
Shawn Pearce9debe632006-02-28 21:43:33 -0500311 if (all)
Junio C Hamano7e44c932008-08-31 09:39:19 -0700312 die("git checkout-index: don't mix '--all' and '--stdin'");
Pierre Habouzit7fb10112007-09-20 00:42:14 +0200313
Junio C Hamanoa392f572016-01-13 16:14:48 -0800314 getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
315 while (getline_fn(&buf, stdin) != EOF) {
Stefan Bellerd7a643b2015-05-04 12:11:54 -0700316 char *p;
Junio C Hamanoa392f572016-01-13 16:14:48 -0800317 if (!nul_term_line && buf.buf[0] == '"') {
Jeff King0d4cc1b2016-01-31 06:25:26 -0500318 strbuf_reset(&unquoted);
319 if (unquote_c_style(&unquoted, buf.buf, NULL))
Pierre Habouzit7fb10112007-09-20 00:42:14 +0200320 die("line is badly quoted");
Jeff King0d4cc1b2016-01-31 06:25:26 -0500321 strbuf_swap(&buf, &unquoted);
Pierre Habouzit7fb10112007-09-20 00:42:14 +0200322 }
323 p = prefix_path(prefix, prefix_length, buf.buf);
Jeff King7e410612020-10-27 03:37:14 -0400324 err |= checkout_file(p, prefix);
Stefan Bellerd7a643b2015-05-04 12:11:54 -0700325 free(p);
Shawn Pearce9debe632006-02-28 21:43:33 -0500326 }
Jeff King0d4cc1b2016-01-31 06:25:26 -0500327 strbuf_release(&unquoted);
Pierre Habouzite6c019d2007-09-17 11:19:04 +0200328 strbuf_release(&buf);
Shawn Pearce9debe632006-02-28 21:43:33 -0500329 }
330
Matheus Tavares70b052b2021-05-04 13:27:30 -0300331 if (all)
332 err |= checkout_all(prefix, prefix_length);
333
334 if (pc_workers > 1)
335 err |= run_parallel_checkout(&state, pc_workers, pc_threshold,
336 NULL, NULL);
337
Jeff King7e410612020-10-27 03:37:14 -0400338 if (err)
339 return 1;
340
Martin Ågren02ae2422017-10-05 22:32:07 +0200341 if (is_lock_file_locked(&lock_file) &&
Nguyễn Thái Ngọc Duy03b86642014-06-13 19:19:23 +0700342 write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
Junio C Hamano021b6e42006-06-06 12:51:49 -0700343 die("Unable to write new index file");
Linus Torvalds33db5f42005-04-09 09:53:05 -0700344 return 0;
345}