checkout: allow "checkout -m path" to unmerge removed paths

"git checkout -m -- path" uses the unmerge_marked_index() API, whose
implementation is incapable of unresolving a path that was resolved
as removed.  Extend the unmerge_index() API function so that we can
mark the ce_flags member of the cache entries we add to the index as
unmerged, and replace use of unmerge_marked_index() with it.

Now, together with its unmerge_index_entry_at() helper function,
unmerge_marked_index() function is no longer called by anybody, and
can safely be removed.

This makes two known test failures in t2070 and t7201 to succeed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2023-07-31 15:44:09 -07:00
parent ed3789f2f0
commit 5bdedac3c7
7 changed files with 13 additions and 82 deletions

View File

@ -646,7 +646,7 @@ static int unresolve_one(const char *path)
item = string_list_lookup(the_index.resolve_undo, path);
if (!item)
return res; /* no resolve-undo record for the path */
res = unmerge_index_entry(&the_index, path, item->util);
res = unmerge_index_entry(&the_index, path, item->util, 0);
FREE_AND_NULL(item->util);
return res;
}