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
@ -299,7 +299,6 @@ static int add_files(struct dir_struct *dir, int flags)
|
||||
int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int exit_status = 0;
|
||||
int newfd;
|
||||
struct pathspec pathspec;
|
||||
struct dir_struct dir;
|
||||
int flags;
|
||||
@ -345,7 +344,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
add_new_files = !take_worktree_changes && !refresh_only;
|
||||
require_pathspec = !take_worktree_changes;
|
||||
|
||||
newfd = hold_locked_index(&lock_file, 1);
|
||||
hold_locked_index(&lock_file, 1);
|
||||
|
||||
flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
|
||||
(show_only ? ADD_CACHE_PRETEND : 0) |
|
||||
@ -443,8 +442,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
|
||||
finish:
|
||||
if (active_cache_changed) {
|
||||
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"));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user