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 29, 2009, 10:13 UTC
Message-ID
<b0943d9e0905290313gc37d98cy769f57a4715cae14@mail.gmail.com>
In-Reply-To
<b0943d9e0905290140i57aeaa33r8de34302b63ffa5e@mail.gmail.com>
2009/5/29 Catalin Marinas <catalin.marinas@gmail.com>:
Show 7 quoted lines
>    merge_bases = repository.get_merge_bases(public_head, stack.base)
>    if not stack.base in merge_bases:
>        public_head = __create_commit(repository, stack.head.data.tree,
>                                      [public_head, stack.base], options)
>        repository.refs.set(public_ref, public_head, 'publish')
>        out.info('Merged the stack base into "%s"' % public_ref)
>        return
One minor improvement here, trying to guess what was merged:
diff --git a/stgit/commands/publish.py b/stgit/commands/publish.py
index fe7f7c6..401fbdf 100644
--- a/stgit/commands/publish.py
+++ b/stgit/commands/publish.py
@@ -67,10 +67,10 @@ options = [

 directory = common.DirectoryHasRepositoryLib()

-def __create_commit(repository, tree, parents, options):
+def __create_commit(repository, tree, parents, options, message = ''):
     """Return a new Commit object."""
     cd = git.CommitData(
-        tree = tree, parents = parents, message = '',
+        tree = tree, parents = parents, message = message,
         author = git.Person.author(), committer = git.Person.committer())
     cd = common.update_commit_data(cd, options, allow_edit = True)

@@ -106,8 +106,10 @@ def func(parser, options, args):
     # base by setting two parents.
     merge_bases = repository.get_merge_bases(public_head, stack.base)
     if not stack.base in merge_bases:
+        message = 'Merge ' + repository.describe(stack.base)
         public_head = __create_commit(repository, stack.head.data.tree,
-                                      [public_head, stack.base], options)
+                                      [public_head, stack.base], options,
+                                      message)
         repository.refs.set(public_ref, public_head, 'publish')
         out.info('Merged the stack base into "%s"' % public_ref)
         return
diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 3303eea..6e3bb4f 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -614,6 +614,10 @@ class Repository(RunWithEnv):
         sha1_list = self.run(['git', 'merge-base', '--all',
                               commit1.sha1, commit2.sha1]).output_lines()
         return set(self.get_commit(sha1) for sha1 in sha1_list)
+    def describe(self, commit):
+        """Use git describe --all on the given commit."""
+        return self.run(['git', 'describe', '--all', commit.sha1]
+                       ).discard_stderr().discard_exitcode().raw_output()
     def simple_merge(self, base, ours, theirs):
         index = self.temp_index()
         try:
-- 
Catalin
Previous: Karl HasselströmNext: Karl Hasselström
Message 8 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.