summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-28 22:24:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-29 01:29:33 (GMT)
commit4cc8d6c62db1f82b3c98468806d2ee54c7e037ca (patch)
tree8c829e1c28c2c8113cfd349c3f3687fcf7cf2b1b /read-cache.c
parent02322e1619dc537dc48650761f6c9bae883612a7 (diff)
downloadgit-4cc8d6c62db1f82b3c98468806d2ee54c7e037ca.zip
git-4cc8d6c62db1f82b3c98468806d2ee54c7e037ca.tar.gz
git-4cc8d6c62db1f82b3c98468806d2ee54c7e037ca.tar.bz2
add -u: do not fail to resolve a path as deleted
After you resolve a conflicted merge to remove the path, "git add -u" failed to record the removal. Instead it errored out by saying that the removed path is not found in the work tree, but that is what the user already knows, and the wanted to record the removal as the resolution, so the error does not make sense. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index b1475ff..940ec76 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)) {