X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=read-cache.c;h=940ec76fdf231ac1345079ca2dc5da88925bcfb6;hb=1d4e4cd4a108dc105f6c8e739c69b9261d4e92a5;hp=b1475ffa0962e1f0238fdb9a6870aa4b0bfd6d3b;hpb=c0f6f67b3d6c8afb89847b6b7bc187d7bed260eb;p=git.git diff --git a/read-cache.c b/read-cache.c index b1475ffa0..940ec76fd 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1574,6 +1574,26 @@ static void update_callback(struct diff_queue_struct *q, default: die("unexpected diff status %c", p->status); case DIFF_STATUS_UNMERGED: + /* + * ADD_CACHE_IGNORE_REMOVAL is unset if "git + * add -u" is calling us, In such a case, a + * missing work tree file needs to be removed + * if there is an unmerged entry at stage #2, + * but such a diff record is followed by + * another with DIFF_STATUS_DELETED (and if + * there is no stage #2, we won't see DELETED + * nor MODIFIED). We can simply continue + * either way. + */ + if (!(data->flags & ADD_CACHE_IGNORE_REMOVAL)) + continue; + /* + * Otherwise, it is "git add path" is asking + * to explicitly add it; we fall through. A + * missing work tree file is an error and is + * caught by add_file_to_index() in such a + * case. + */ case DIFF_STATUS_MODIFIED: case DIFF_STATUS_TYPE_CHANGED: if (add_file_to_index(&the_index, path, data->flags)) {