From: Catalin Marinas <catalin.marinas@gmail.com>
To: "Karl Hasselström" <kha@treskal.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC][StGit PATCH] Add support for merge-friendly branches
Date: Thu, 28 May 2009 15:51:20 +0100 [thread overview]
Message-ID: <b0943d9e0905280751k3b9f26c9gd907a7c11ca9d5e2@mail.gmail.com> (raw)
In-Reply-To: <b0943d9e0905280738n51476ab7vd0498ea7a236c4a7@mail.gmail.com>
2009/5/28 Catalin Marinas <catalin.marinas@gmail.com>:
> 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
next prev parent reply other threads:[~2009-05-28 14:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 11:12 [RFC][StGit PATCH] Add support for merge-friendly branches Catalin Marinas
[not found] ` <20090528111212.21925.45527.stgit-hhZApKj8DF/YkXV2EHHjLW3o5bpOHsLO@public.gmane.org>
2009-05-28 12:12 ` Fwd: " martin f krafft
2009-05-28 12:48 ` Karl Hasselström
2009-05-28 14:38 ` Catalin Marinas
2009-05-28 14:51 ` Catalin Marinas [this message]
2009-05-29 7:20 ` Karl Hasselström
2009-05-29 8:40 ` Catalin Marinas
2009-05-29 9:12 ` Karl Hasselström
2009-05-29 10:13 ` Catalin Marinas
2009-05-29 8:37 ` Karl Hasselström
2009-05-29 9:16 ` Catalin Marinas
2009-05-29 11:59 ` 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=b0943d9e0905280751k3b9f26c9gd907a7c11ca9d5e2@mail.gmail.com \
--to=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
--cc=kha@treskal.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).