Merge 'js/add-i-delete' into maint-2.37
Rewrite of "git add -i" in C that appeared in Git 2.25 didn't correctly record a removed file to the index, which is an old regression but has become widely known because the C version has become the default in the latest release. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -697,8 +697,16 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps,
|
||||
|
||||
for (i = 0; i < files->items.nr; i++) {
|
||||
const char *name = files->items.items[i].string;
|
||||
if (files->selected[i] &&
|
||||
add_file_to_index(s->r->index, name, 0) < 0) {
|
||||
struct stat st;
|
||||
|
||||
if (!files->selected[i])
|
||||
continue;
|
||||
if (lstat(name, &st) && is_missing_file_error(errno)) {
|
||||
if (remove_file_from_index(s->r->index, name) < 0) {
|
||||
res = error(_("could not stage '%s'"), name);
|
||||
break;
|
||||
}
|
||||
} else if (add_file_to_index(s->r->index, name, 0) < 0) {
|
||||
res = error(_("could not stage '%s'"), name);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user