summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bf41bf2)
raw | patch | inline | side by side (parent: bf41bf2)
author | Junio C Hamano <junkio@cox.net> | |
Sat, 3 Jun 2006 08:49:31 +0000 (01:49 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 4 Jun 2006 06:57:41 +0000 (23:57 -0700) |
The earlier "git reset --hard" simplification stopped removing
leftover working tree files from a failed automerge, when
switching back to the HEAD version that does not have the
paths.
This patch, instead of removing the unmerged paths from the
index, drops them down to stage#0 but marks them with mode=0
(the same "to be deleted" marker we internally use for paths
deleted by the merge). one_way_merge() function and the
functions it calls already know what to do with them -- if the
tree we are reading has the path the working tree file is
overwritten, and if it doesn't the working tree file is
removed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
leftover working tree files from a failed automerge, when
switching back to the HEAD version that does not have the
paths.
This patch, instead of removing the unmerged paths from the
index, drops them down to stage#0 but marks them with mode=0
(the same "to be deleted" marker we internally use for paths
deleted by the merge). one_way_merge() function and the
functions it calls already know what to do with them -- if the
tree we are reading has the path the working tree file is
overwritten, and if it doesn't the working tree file is
removed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-read-tree.c | patch | blob | history |
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 716f7925142bca11cf7ab5438ce5908e55285463..21361dff42e441a93b83000996a91a3a77bc1bd1 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
static int read_cache_unmerged(void)
{
- int i, deleted;
+ int i;
struct cache_entry **dst;
+ struct cache_entry *last = NULL;
read_cache();
dst = active_cache;
- deleted = 0;
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce)) {
- deleted++;
+ if (last && !strcmp(ce->name, last->name))
+ continue;
invalidate_ce_path(ce);
- continue;
+ last = ce;
+ ce->ce_mode = 0;
+ ce->ce_flags &= ~htons(CE_STAGEMASK);
}
- if (deleted)
- *dst = ce;
- dst++;
+ *dst++ = ce;
}
- active_nr -= deleted;
- return deleted;
+ active_nr = dst - active_cache;
+ return !!last;
}
static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
continue;
}
- /* This differs from "-m" in that we'll silently ignore unmerged entries */
+ /* This differs from "-m" in that we'll silently ignore
+ * unmerged entries and overwrite working tree files that
+ * correspond to them.
+ */
if (!strcmp(arg, "--reset")) {
if (stage || merge)
usage(read_tree_usage);