Re: [RFC][StGit PATCH] Add support for merge-friendly branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/5/28 Catalin Marinas <catalin.marinas@xxxxxxxxx>:
> 2009/5/28 Karl Hasselström <kha@xxxxxxxxxxx>:
>> On 2009-05-28 12:12:42 +0100, Catalin Marinas wrote:
>>> +    def get_merge_base(self, commit1, commit2):
>>> +        """Return the merge base of two commits."""
>>> +        sha1 = self.run(['git', 'merge-base',
>>> +                         commit1.sha1, commit2.sha1]).output_one_line()
>>> +        return self.get_commit(sha1)
>>
>> This funcion should probably return a list of zero or more merge
>> bases. See the --all flag to git merge-base.
>
> OK, I'll add this and check the stack base against this set(list).

What about this change to the original patch (it's faster to just
return the sha1 refs than building the Commit objects):


diff --git a/stgit/commands/publish.py b/stgit/commands/publish.py
index 06c32d0..ce08a19 100644
--- a/stgit/commands/publish.py
+++ b/stgit/commands/publish.py
@@ -106,8 +106,8 @@ def func(parser, options, args):

     # check for rebased stack. In this case we emulate a merge with the stack
     # base by setting two parents.
-    merge_base = repository.get_merge_base(public_head, stack.base)
-    if merge_base.sha1 != stack.base.sha1:
+    merge_base = set(repository.get_merge_base_sha1(public_head, stack.base))
+    if not stack.base.sha1 in merge_base:
         public_head = __create_commit(repository, stack.head.data.tree,
                                       [public_head, stack.base], options)
         repository.refs.set(public_ref, public_head, 'publish')
diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 4a17c8a..5bd4e4d 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -609,11 +609,10 @@ class Repository(RunWithEnv):
             raise DetachedHeadException()
     def set_head_ref(self, ref, msg):
         self.run(['git', 'symbolic-ref', '-m', msg, 'HEAD', ref]).no_output()
-    def get_merge_base(self, commit1, commit2):
-        """Return the merge base of two commits."""
-        sha1 = self.run(['git', 'merge-base',
-                         commit1.sha1, commit2.sha1]).output_one_line()
-        return self.get_commit(sha1)
+    def get_merge_base_sha1(self, commit1, commit2):
+        """Return the merge base of two commits as a list of sha1 refs."""
+        return self.run(['git', 'merge-base', '--all',
+                         commit1.sha1, commit2.sha1]).output_lines()
     def simple_merge(self, base, ours, theirs):
         index = self.temp_index()
         try:

-- 
Catalin
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]