+/*
+ * When a CE gets turned into an unmerged entry, we
+ * want it to be up-to-date
+ */
+static void verify_uptodate(struct cache_entry *ce)
+{
+ struct stat st;
+
+ if (!lstat(ce->name, &st)) {
+ unsigned changed = ce_match_stat(ce, &st);
+ if (!changed)
+ return;
+ errno = 0;
+ }
+ if (errno == ENOENT)
+ return;
+ die("Entry '%s' not uptodate. Cannot merge.", ce->name);
+}
+
+/*
+ * If the old tree contained a CE that isn't even in the
+ * result, that's always a problem, regardless of whether
+ * it's up-to-date or not (ie it can be a file that we
+ * have updated but not committed yet).
+ */
+static void verify_cleared(struct cache_entry *ce)
+{
+ if (ce)
+ die("Entry '%s' would be overwritten by merge. Cannot merge.", ce->name);
+}
+
+static int old_match(struct cache_entry *old, struct cache_entry *a)
+{
+ return old && path_matches(old, a) && same(old, a);
+}
+