summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ca016f0)
raw | patch | inline | side by side (parent: ca016f0)
author | Linus Torvalds <torvalds@ppc970.osdl.org.(none)> | |
Tue, 19 Apr 2005 18:41:18 +0000 (11:41 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org.(none)> | |
Tue, 19 Apr 2005 18:41:18 +0000 (11:41 -0700) |
This one just reads one tree, but picks up any matching stat information
from the old index.
from the old index.
read-tree.c | patch | blob | history |
diff --git a/read-tree.c b/read-tree.c
index abb522550f3d113901d352e0d5e5c77459fef3eb..46747b5e99b102ed547e87f55a8ee734c9ddb074 100644 (file)
--- a/read-tree.c
+++ b/read-tree.c
nr -= 2;
active_nr -= 2;
}
- *dst = ce;
+ *dst++ = ce;
+ src++;
+ nr--;
+ }
+}
+
+static void merge_stat_info(struct cache_entry **src, int nr)
+{
+ static struct cache_entry null_entry;
+ struct cache_entry **dst = src;
+ struct cache_entry *old = &null_entry;
+
+ while (nr) {
+ struct cache_entry *ce;
+
+ ce = src[0];
+
+ /* We throw away original cache entries except for the stat information */
+ if (!ce_stage(ce)) {
+ old = ce;
+ src++;
+ nr--;
+ active_nr--;
+ continue;
+ }
+ if (path_matches(ce, old) && same(ce, old))
+ *ce = *old;
+ ce->ce_flags &= ~htons(CE_STAGEMASK);
+ *dst++ = ce;
src++;
- dst++;
nr--;
}
}
stage++;
}
if (merge) {
- if (stage != 4)
- usage("I need three trees to merge: original, branch1 and branch2");
- trivially_merge_cache(active_cache, active_nr);
+ switch (stage) {
+ case 4: /* Three-way merge */
+ trivially_merge_cache(active_cache, active_nr);
+ break;
+ case 2: /* Just read a tree, merge with old cache contents */
+ merge_stat_info(active_cache, active_nr);
+ break;
+ default:
+ die("just how do you expect me to merge %d trees?", stage-1);
+ }
}
if (write_cache(newfd, active_cache, active_nr) ||
rename(".git/index.lock", ".git/index"))