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

[StGit PATCH] Import git show output easily

From
CMCatalin Marinas <catalin.marinas@arm.com>
Date
Sep 2, 2009, 17:50 UTC
Message-ID
<20090902175039.21633.25294.stgit@pc1117.cambridge.arm.com>

This patch modifies the import command to check for standard 'git show' output and parse it accordingly.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
 stgit/commands/common.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/stgit/commands/common.py b/stgit/commands/common.py
index d38d263..0d39148 100644
--- a/stgit/commands/common.py
+++ b/stgit/commands/common.py
@@ -355,6 +355,7 @@ def __parse_description(descr):
 
     lasthdr = 0
     end = len(descr_lines)
+    descr_strip = 0
 
     # Parse the patch header
     for pos in range(0, end):
@@ -374,12 +375,16 @@ def __parse_description(descr):
         if subject:
             break
         # get the subject
-        subject = descr_lines[pos]
+        subject = descr_lines[pos][descr_strip:]
+        if re.match('commit [\da-f]{40}$', subject):
+            # 'git show' output, look for the real subject
+            subject = ''
+            descr_strip = 4
         lasthdr = pos + 1
 
     # get the body
     if lasthdr < end:
-        body = reduce(lambda x, y: x + '\n' + y, descr_lines[lasthdr:], '')
+        body = '\n' + '\n'.join(l[descr_strip:] for l in descr_lines[lasthdr:])
 
     return (subject + body, authname, authemail, authdate)
 
Next: Gustav Hållberg
Message 1 of 3 in “Import git show output easily”
  1. Import git show output easilyCatalin Marinas, Sep 2, 2009
  2. Gustav HållbergSep 2, 2009
  3. Catalin MarinasSep 2, 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.