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

[PATCH] Allow hand-editing of patches before sending

From
Karl Hasselström <kha@treskal.com>
Date
Nov 1, 2006, 09:00 UTC
Message-ID
<20061101090046.1107.81105.stgit@localhost>
From: Karl Hasselström <kha@treskal.com>

This adds a new flag to 'stg mail', allowing the user to hand-edit each patch e-mail before it is sent, just like it is currently possible to edit the cover message.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---

Intended use is to allow the user to write comments like this, when there is only one patch and a cover mail would be overkill.

 stgit/commands/mail.py |   59 ++++++++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index 970ae3e..26c711d 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -108,6 +108,9 @@ options = [make_option('-a', '--all',
            make_option('-e', '--edit',
                        help = 'edit the cover message before sending',
                        action = 'store_true'),
+           make_option('-E', '--edit-patches',
+                       help = 'edit each patch before sending',
+                       action = 'store_true'),
            make_option('-s', '--sleep', type = 'int', metavar = 'SECONDS',
                        help = 'sleep for SECONDS between e-mails sending'),
            make_option('--refid',
@@ -276,6 +279,34 @@ def __build_extra_headers():
 
     return headers
 
+def edit_message(msg):
+    fname = '.stgitmail.txt'
+
+    # create the initial file
+    f = file(fname, 'w')
+    f.write(msg)
+    f.close()
+
+    # the editor
+    if config.has_option('stgit', 'editor'):
+        editor = config.get('stgit', 'editor')
+    elif 'EDITOR' in os.environ:
+        editor = os.environ['EDITOR']
+    else:
+        editor = 'vi'
+    editor += ' %s' % fname
+
+    print 'Invoking the editor: "%s"...' % editor,
+    sys.stdout.flush()
+    print 'done (exit code: %d)' % os.system(editor)
+
+    # read the message back
+    f = file(fname)
+    msg = f.read()
+    f.close()
+
+    return msg
+
 def __build_cover(tmpl, total_nr, msg_id, options):
     """Build the cover message (series description) to be sent via SMTP
     """
@@ -326,30 +357,7 @@ def __build_cover(tmpl, total_nr, msg_id
               'supported in the patch template'
 
     if options.edit:
-        fname = '.stgitmail.txt'
-
-        # create the initial file
-        f = file(fname, 'w+')
-        f.write(msg)
-        f.close()
-
-        # the editor
-        if config.has_option('stgit', 'editor'):
-            editor = config.get('stgit', 'editor')
-        elif 'EDITOR' in os.environ:
-            editor = os.environ['EDITOR']
-        else:
-            editor = 'vi'
-        editor += ' %s' % fname
-
-        print 'Invoking the editor: "%s"...' % editor,
-        sys.stdout.flush()
-        print 'done (exit code: %d)' % os.system(editor)
-
-        # read the message back
-        f = file(fname)
-        msg = f.read()
-        f.close()
+        msg = edit_message(msg)
 
     return msg.strip('\n')
 
@@ -431,6 +439,9 @@ def __build_message(tmpl, patch, patch_n
         raise CmdException, 'Only "%(name)s" variables are ' \
               'supported in the patch template'
 
+    if options.edit_patches:
+        msg = edit_message(msg)
+
     return msg.strip('\n')
 
Next: Catalin Marinas
Message 1 of 31 in “Allow hand-editing of patches before sending”
  1. Allow hand-editing of patches before sendingKarl Hasselström, Nov 1, 2006
  2. Catalin MarinasNov 2, 2006
  3. Karl HasselströmNov 2, 2006
  4. Catalin MarinasNov 3, 2006
  5. Karl HasselströmNov 3, 2006
  6. Karl HasselströmNov 3, 2006
  7. Petr BaudisNov 3, 2006
  8. Robin RosenbergNov 3, 2006
  9. Andreas EricssonNov 3, 2006
  10. Karl HasselströmNov 3, 2006
  11. Junio C HamanoNov 3, 2006
  12. Karl HasselströmNov 3, 2006
  13. Catalin MarinasNov 3, 2006
  14. Andy WhitcroftNov 3, 2006
  15. Karl HasselströmNov 3, 2006
  16. Andy WhitcroftNov 3, 2006
  17. Linus TorvaldsNov 3, 2006
  18. Karl HasselströmNov 5, 2006
  19. Linus TorvaldsNov 5, 2006
  20. Karl HasselströmNov 5, 2006
  21. Catalin MarinasNov 3, 2006
  22. Karl HasselströmNov 3, 2006
  23. Catalin MarinasNov 3, 2006
  24. Karl HasselströmNov 3, 2006
  25. Catalin MarinasNov 3, 2006
  26. Karl HasselströmNov 3, 2006
  27. Karl HasselströmNov 3, 2006
  28. Catalin MarinasNov 3, 2006
  29. Catalin MarinasNov 3, 2006
  30. Petr BaudisNov 3, 2006
  31. Catalin MarinasNov 3, 2006

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.