How to add additional text when sending an email with git send-email?

前端 未结 3 703
陌清茗
陌清茗 2021-02-08 15:55

I am sending patches using git send-email .

I want that the email sent with the patch to have some additional text added at the top, besid

相关标签:
3条回答
  • 2021-02-08 16:12

    Documentation says that you can add --compose option to git send-email to "Invoke a text editor to edit an introductory message for the patch series."

    If you want to automate this action and generate some text by your script. You could set $GIT_EDITOR environment variable to your script. It will receive temporary file name for the text in the command line argument. Contents of this file will be inserted into the message after your script exit.

    Command for git send-email will look like:

    $GIT_EDITOR="/path/to/your/script" git send-email ...
    

    And your script could look like:

    #!/bin/bash
    
    echo "Your message" > $1
    
    0 讨论(0)
  • 2021-02-08 16:23

    Git 2.18 (Q2 2018) offers an alternative to --annotate or --compose for adding additional text when sending an email with git send-email.

    See commit 04c4a4e (04 May 2018) by Drew DeVault (SirCmpwn).
    Helped-by: Eric Wong (ele828).
    (Merged by Junio C Hamano -- gitster -- in commit 89be19d, 30 May 2018)

    git-send-email: allow re-editing of message

    When shown the email summary, an opportunity is presented for the user to edit the email as if they had specified --annotate.
    This also permits them to edit it multiple times.

    "git send-email" can sometimes offer confirmation dialog "Send this email?" with choices 'Yes', 'No', 'Quit', and 'All'.
    A new action 'Edit' has been added to this dialog's choice.

    As seen in git-send-email.perl:

    # If the user decides they want to make further edits, -1 is returned and the
    # caller is expected to call send_message again after the edits are performed.
    
    0 讨论(0)
  • 2021-02-08 16:24

    You can use --annotate, then just add your comment between the two --- of the patch, it won't affect the very patch.

    Ref: https://kparal.wordpress.com/2011/08/03/git-tip-of-the-day-introduction-text-when-emailing-patches/

    eg:

    From 7ea3c50fa83950549de11c6834c465bc8f28b52b Mon Sep 17 00:00:00 2001
    From: James Laska
    Date: Mon, 1 Aug 2011 09:53:16 -0400
    Subject: [PATCH] compose_tree - Save the setup.sh script for later debugging
    
    ---
    This patch is really really important, because otherwise the 
    world will end in 2012. Please accept it.
    
     tests/compose_tree/compose_tree.sh |    2 ++
     1 files changed, 2 insertions(+), 0 deletions(-)
    
    diff --git a/tests/compose_tree/compose_tree.sh b/tests/compose_tree/compose_tree.sh
    index 66ecefd..c2e041d 100755
    --- a/tests/compose_tree/compose_tree.sh
    +++ b/tests/compose_tree/compose_tree.sh
    ... (the rest of the patch)
    
    0 讨论(0)
提交回复
热议问题