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
@ -657,14 +657,12 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
|
||||
struct commit_list *remoteheads,
|
||||
struct commit *head, const char *head_arg)
|
||||
{
|
||||
int index_fd;
|
||||
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
|
||||
|
||||
index_fd = hold_locked_index(lock, 1);
|
||||
hold_locked_index(lock, 1);
|
||||
refresh_cache(REFRESH_QUIET);
|
||||
if (active_cache_changed &&
|
||||
(write_cache(index_fd, active_cache, active_nr) ||
|
||||
commit_locked_index(lock)))
|
||||
write_locked_index(&the_index, lock, COMMIT_LOCK))
|
||||
return error(_("Unable to write index."));
|
||||
rollback_lock_file(lock);
|
||||
|
||||
@ -672,7 +670,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
|
||||
int clean, x;
|
||||
struct commit *result;
|
||||
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
|
||||
int index_fd;
|
||||
struct commit_list *reversed = NULL;
|
||||
struct merge_options o;
|
||||
struct commit_list *j;
|
||||
@ -700,12 +697,11 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
|
||||
for (j = common; j; j = j->next)
|
||||
commit_list_insert(j->item, &reversed);
|
||||
|
||||
index_fd = hold_locked_index(lock, 1);
|
||||
hold_locked_index(lock, 1);
|
||||
clean = merge_recursive(&o, head,
|
||||
remoteheads->item, reversed, &result);
|
||||
if (active_cache_changed &&
|
||||
(write_cache(index_fd, active_cache, active_nr) ||
|
||||
commit_locked_index(lock)))
|
||||
write_locked_index(&the_index, lock, COMMIT_LOCK))
|
||||
die (_("unable to write %s"), get_index_file());
|
||||
rollback_lock_file(lock);
|
||||
return clean ? 0 : 1;
|
||||
|
||||
Reference in New Issue
Block a user