die("Entry '%s' not uptodate. Cannot merge.", ce->name);
}
+static void invalidate_ce_path(struct cache_entry *ce)
+{
+ if (ce)
+ cache_tree_invalidate_path(active_cache_tree, ce->name);
+}
+
+ /*
+ * We do not want to remove or overwrite a working tree file that
+ * is not tracked.
+ */
+ static void verify_absent(const char *path, const char *action)
+ {
+ struct stat st;
+
+ if (index_only || reset || !update)
+ return;
+ if (!lstat(path, &st))
+ die("Untracked working tree file '%s' "
+ "would be %s by merge.", path, action);
+ }
+
static int merged_entry(struct cache_entry *merge, struct cache_entry *old)
{
merge->ce_flags |= htons(CE_UPDATE);
*merge = *old;
} else {
verify_uptodate(old);
+ invalidate_ce_path(old);
}
}
-- else
++ else {
+ verify_absent(merge->name, "overwritten");
+ invalidate_ce_path(merge);
++ }
+
merge->ce_flags &= ~htons(CE_STAGEMASK);
add_cache_entry(merge, ADD_CACHE_OK_TO_ADD);
return 1;
{
if (old)
verify_uptodate(old);
+ else
+ verify_absent(ce->name, "removed");
ce->ce_mode = 0;
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD);
+ invalidate_ce_path(ce);
return 1;
}
return error("Cannot do a oneway merge of %d trees",
merge_size);
- if (!a)
+ if (!a) {
+ invalidate_ce_path(old);
- return deleted_entry(old, NULL);
+ return deleted_entry(old, old);
+ }
if (old && same(old, a)) {
if (reset) {
struct stat st;