From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH 1/2] Do simple in-index merge with diff+apply instead of read-tree
Date: Wed, 02 Jul 2008 08:12:44 +0200 [thread overview]
Message-ID: <20080702061243.11361.75544.stgit@yoghurt> (raw)
In-Reply-To: <20080702060113.11361.39006.stgit@yoghurt>
The advantage is that patch application will resolve some file content
conflicts for us, so that we'll fall back to merge-recursive less
often. This is a significant speedup, especially since merge-recursive
needs to touch the worktree, which means we have to check out the
index first.
(A simple test, pushing 250 patches in a 32k-file repository, with one
file-level merge necessary per push, went from 1.07 to 0.36 seconds
per patch with this patch applied.)
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/lib/git.py | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 6ccdfa7..a38eaa5 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -475,9 +475,10 @@ class Repository(RunWithEnv):
return ours
index = self.temp_index()
+ index.read_tree(ours)
try:
- index.merge(base, ours, theirs)
try:
+ index.apply_treediff(base, theirs)
return index.write_tree()
except MergeException:
return None
@@ -548,10 +549,6 @@ class Index(RunWithEnv):
return False
else:
return True
- def merge(self, base, ours, theirs):
- """In-index merge, no worktree involved."""
- self.run(['git', 'read-tree', '-m', '-i', '--aggressive',
- base.sha1, ours.sha1, theirs.sha1]).no_output()
def apply(self, patch_text):
"""In-index patch application, no worktree involved."""
try:
@@ -559,6 +556,12 @@ class Index(RunWithEnv):
).raw_input(patch_text).no_output()
except run.RunException:
raise MergeException('Patch does not apply cleanly')
+ def apply_treediff(self, tree1, tree2):
+ """Apply the diff from C{tree1} to C{tree2} to the index."""
+ # Passing --full-index here is necessary to support binary
+ # files. It is also sufficient, since the repository already
+ # contains all involved objects.
+ self.apply(self.__repository.diff_tree(tree1, tree2, ['--full-index']))
def delete(self):
if os.path.isfile(self.__filename):
os.remove(self.__filename)
next prev parent reply other threads:[~2008-07-02 6:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-02 6:12 [StGit PATCH 0/2] push optimizations Karl Hasselström
2008-07-02 6:12 ` Karl Hasselström [this message]
2008-07-12 10:22 ` [StGit PATCH 1/2] Do simple in-index merge with diff+apply instead of read-tree Catalin Marinas
2008-07-02 6:13 ` [StGit PATCH 2/2] Reuse the same temp index in a transaction Karl Hasselström
2008-07-03 21:38 ` [StGit PATCH v2] " Karl Hasselström
2008-07-12 10:24 ` [StGit PATCH 2/2] " Catalin Marinas
2008-07-14 6:35 ` Karl Hasselström
2008-07-07 21:12 ` [StGit PATCH 0/2] push optimizations Catalin Marinas
2008-07-08 4:36 ` Karl Hasselström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080702061243.11361.75544.stgit@yoghurt \
--to=kha@treskal.com \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.