summaryrefslogtreecommitdiff
path: root/lib/git/index
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-24 16:02:28 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-24 18:08:40 +0200
commit55dcc17c331f580b3beeb4d5decf64d3baf94f2e (patch)
tree9b22eac76156f87e307ea33294791bc820fd3167 /lib/git/index
parent129f90aa8d83d9b250c87b0ba790605c4a2bb06a (diff)
downloadgitpython-55dcc17c331f580b3beeb4d5decf64d3baf94f2e.tar.gz
aggressive_tree_merge: fixed incorrect handling of one branch, it was just not implemented causing incorrect merge results. Added test to cover this issue
Diff: added NULL_BIN_SHA constant for completeness
Diffstat (limited to 'lib/git/index')
-rw-r--r--lib/git/index/base.py5
-rw-r--r--lib/git/index/fun.py11
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/git/index/base.py b/lib/git/index/base.py
index 771f1710..7568b476 100644
--- a/lib/git/index/base.py
+++ b/lib/git/index/base.py
@@ -530,9 +530,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
:raise ValueError: if there are no entries in the cache
:raise UnmergedEntriesError: """
# we obtain no lock as we just flush our contents to disk as tree
- if not self.entries:
- raise ValueError("Cannot write empty index")
-
+ # If we are a new index, the entries access will load our data accordingly
mdb = MemoryDB()
entries = self._entries_sorted()
binsha, tree_items = write_tree_from_cache(entries, mdb, slice(0, len(entries)))
@@ -892,7 +890,6 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
return out
- @default_index
def commit(self, message, parent_commits=None, head=True):
"""
Commit the current default index file, creating a commit object.
diff --git a/lib/git/index/fun.py b/lib/git/index/fun.py
index 23a6d8f9..14a47fdc 100644
--- a/lib/git/index/fun.py
+++ b/lib/git/index/fun.py
@@ -283,7 +283,16 @@ def aggressive_tree_merge(odb, tree_shas):
elif theirs is None:
# added in our branch
out_append(_tree_entry_to_baseindexentry(ours, 0))
- # END hanle heads
+ else:
+ # both have it, except for the base, see whether it changed
+ if ours[0] != theirs[0] or ours[1] != theirs[1]:
+ out_append(_tree_entry_to_baseindexentry(ours, 2))
+ out_append(_tree_entry_to_baseindexentry(theirs, 3))
+ else:
+ # it was added the same in both
+ out_append(_tree_entry_to_baseindexentry(ours, 0))
+ # END handle two items
+ # END handle heads
# END handle base exists
# END for each entries tuple