git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
CMCatalin Marinas <catalin.marinas@gmail.com>
Date
May 28, 2009, 14:51 UTC
Message-ID
<b0943d9e0905280751k3b9f26c9gd907a7c11ca9d5e2@mail.gmail.com>
In-Reply-To
<b0943d9e0905280738n51476ab7vd0498ea7a236c4a7@mail.gmail.com>
2009/5/28 Catalin Marinas <catalin.marinas@gmail.com>:
Show 12 quoted lines
> 2009/5/28 Karl Hasselström <kha@treskal.com>:
>> 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
Previous: Catalin MarinasNext: Karl Hasselström
Message 4 of 12 in “Add support for merge-friendly branches”
  1. Catalin MarinasMay 28, 2009
  2. Karl HasselströmMay 28, 2009
  3. Catalin MarinasMay 28, 2009
  4. Catalin MarinasMay 28, 2009
  5. Karl HasselströmMay 29, 2009
  6. Catalin MarinasMay 29, 2009
  7. Karl HasselströmMay 29, 2009
  8. Catalin MarinasMay 29, 2009
  9. Karl HasselströmMay 29, 2009
  10. Catalin MarinasMay 29, 2009
  11. Karl HasselströmMay 29, 2009
  12. Fwd: [RFC][StGit PATCH] Add support for merge-friendly branchesmartin f krafft, May 28, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.