diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2007-08-10 12:53:51 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-08-10 23:02:14 -0700 |
commit | 566b5c057c452d04605805ea2f7af210c6fb9b59 (patch) | |
tree | 61191e80bae32d7f74fb433fc2a6f74d145162c3 /unpack-trees.c | |
parent | cbbb218f8bd219d79907623a9304496ee69d8abd (diff) | |
download | git-566b5c057c452d04605805ea2f7af210c6fb9b59.tar.gz git-566b5c057c452d04605805ea2f7af210c6fb9b59.tar.xz |
Optimize the three-way merge of git-read-tree
As mentioned, the three-way case *should* be as trivial as the
following. It passes all the tests, and I verified that a conflicting
merge in the 100,000 file horror-case merged correctly (with the conflict
markers) in 0.687 seconds with this, so it works, but I'm lazy and
somebody else should double-check it [jc: followed all three-way merge
codepaths and verified it removes when it should].
Without this patch, the merge took 8.355 seconds, so this patch
really does make a huge difference for merge performance with lots and
lots of files, and we're not talking percentages, we're talking
orders-of-magnitude differences!
Now "unpack_trees()" is just fast enough that we don't need to avoid it
(although it's probably still a good idea to eventually convert it to use
the traverse_trees() infrastructure some day - just to avoid having
extraneous tree traversal functions).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index fda7729f1..ccfeb6e24 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -667,7 +667,6 @@ int threeway_merge(struct cache_entry **stages, int no_anc_exists = 1; int i; - remove_entry(remove); for (i = 1; i < o->head_idx; i++) { if (!stages[i] || stages[i] == o->df_conflict_entry) any_anc_missing = 1; @@ -730,8 +729,10 @@ int threeway_merge(struct cache_entry **stages, } /* #1 */ - if (!head && !remote && any_anc_missing) + if (!head && !remote && any_anc_missing) { + remove_entry(remove); return 0; + } /* Under the new "aggressive" rule, we resolve mostly trivial * cases that we historically had git-merge-one-file resolve. @@ -763,6 +764,7 @@ int threeway_merge(struct cache_entry **stages, if ((head_deleted && remote_deleted) || (head_deleted && remote && remote_match) || (remote_deleted && head && head_match)) { + remove_entry(remove); if (index) return deleted_entry(index, index, o); else if (ce && !head_deleted) @@ -785,6 +787,7 @@ int threeway_merge(struct cache_entry **stages, verify_uptodate(index, o); } + remove_entry(remove); o->nontrivial_merge = 1; /* #2, #3, #4, #6, #7, #9, #10, #11. */ |