read-cache: new API write_locked_index instead of write_index/write_cache
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
33c297aacc
commit
03b8664772
@ -225,7 +225,6 @@ static int checkout_paths(const struct checkout_opts *opts,
|
||||
int flag;
|
||||
struct commit *head;
|
||||
int errs = 0;
|
||||
int newfd;
|
||||
struct lock_file *lock_file;
|
||||
|
||||
if (opts->track != BRANCH_TRACK_UNSPECIFIED)
|
||||
@ -256,7 +255,7 @@ static int checkout_paths(const struct checkout_opts *opts,
|
||||
|
||||
lock_file = xcalloc(1, sizeof(struct lock_file));
|
||||
|
||||
newfd = hold_locked_index(lock_file, 1);
|
||||
hold_locked_index(lock_file, 1);
|
||||
if (read_cache_preload(&opts->pathspec) < 0)
|
||||
return error(_("corrupt index file"));
|
||||
|
||||
@ -352,8 +351,7 @@ static int checkout_paths(const struct checkout_opts *opts,
|
||||
}
|
||||
}
|
||||
|
||||
if (write_cache(newfd, active_cache, active_nr) ||
|
||||
commit_locked_index(lock_file))
|
||||
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
|
||||
die(_("unable to write new index file"));
|
||||
|
||||
read_ref_full("HEAD", rev, 0, &flag);
|
||||
@ -444,8 +442,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
||||
{
|
||||
int ret;
|
||||
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
|
||||
int newfd = hold_locked_index(lock_file, 1);
|
||||
|
||||
hold_locked_index(lock_file, 1);
|
||||
if (read_cache_preload(NULL) < 0)
|
||||
return error(_("corrupt index file"));
|
||||
|
||||
@ -553,8 +551,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
||||
}
|
||||
}
|
||||
|
||||
if (write_cache(newfd, active_cache, active_nr) ||
|
||||
commit_locked_index(lock_file))
|
||||
if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
|
||||
die(_("unable to write new index file"));
|
||||
|
||||
if (!opts->force && !opts->quiet)
|
||||
|
Reference in New Issue
Block a user