{"thread":{"id":"36944","subject":"[PATCH RFC v2] git-am: support any number of signatures","startedAt":"2014-06-18T04:34:29Z","lastAt":"2014-06-18T04:34:29Z","messageCount":1,"participants":["Michael S. Tsirkin"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"244499","messageId":"1403065765-22598-1-git-send-email-mst@redhat.com","threadId":"36944","inReplyTo":null,"subject":"[PATCH RFC v2] git-am: support any number of signatures","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2014-06-18T04:34:29Z","receivedAt":"2014-06-18T04:34:29Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"I'm using different signature tags for git am depending on the patch,\nproject and other factors.\n\nSometimes I add multiple tags as well, e.g. QEMU\nwants both Reviewed-by and Signed-off-by tags.\n\nThis patch makes it easy to do so:\n1.  new parameter am.signoff can be used any number\n\tof times:\n\n[am]\n\tsignoff = \"Reviewed-by: Michael S. Tsirkin <mst@redhat.com>\"\n\n\tWill add reviewed by tag in addition to the S.O.B.\n\tif set all signatures are picked up when git am -s is used.\n\n2.  Any number of alternative signatures\n\n[am \"a\"]\n\tsignoff = \"Acked-by: Michael S. Tsirkin <mst@redhat.com>\"\n[am \"t\"]\n\tsignoff = \"Tested-by: Michael S. Tsirkin <mst@redhat.com>\"\n\n\tif set the signature type can be specified by passing\n\ta parameter to the -s flag:\n\n\tgit am -sa\n\nA combination is supported:\n\tgit am -sa -st\n\nNo docs or tests, sorry, so not yet ready for master, but I'm using this\nall the time without any issues so maybe ok for pu.\nEarly flames/feedback/help welcome.\n\nChanges from v1:\n\tAddress Junio's feedback:\n\tDefault signature is always applied.\n\tThis is to make it a no-brainer for people to track using DCO.\n\tDe-duplication fixed (works for default signature only\n\tas other signatures might make sense multiple times).\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n git-am.sh | 28 +++++++++++++++++++++++-----\n 1 file changed, 23 insertions(+), 5 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex ee61a77..c1246e6 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -13,7 +13,7 @@ i,interactive   run interactively\n b,binary*       (historical option -- no-op)\n 3,3way          allow fall back on 3way merging if needed\n q,quiet         be quiet\n-s,signoff       add a Signed-off-by line to the commit message\n+s,signoff?      add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n keep-non-patch  pass -b flag to git-mailinfo\n@@ -383,6 +383,7 @@ then\n     keepcr=t\n fi\n \n+signoffs=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -394,8 +395,15 @@ it will be removed. Please do not use it anymore.\"\n \t\t;;\n \t-3|--3way)\n \t\tthreeway=t ;;\n-\t-s|--signoff)\n-\t\tsign=t ;;\n+\t--signoff)\n+\t\tsign=t\n+\t\ts=$(git config --get-all am.signoff)\n+\t\tsignoffs=(\"${signoffs[@]}\" \"${s[@]}\") ;;\n+\t--signoff=*)\n+\t\tsign=t\n+\t\ta=\"${1#--signoff=}\"\n+\t\ts=$(git config --get-all am.\"${a}\".signoff)\n+\t\tsignoffs=(\"${signoffs[@]}\" \"${s[@]}\") ;;\n \t-u|--utf8)\n \t\tutf8=t ;; # this is now default\n \t--no-utf8)\n@@ -642,6 +650,16 @@ then\n \tthreeway=t\n fi\n git_apply_opt=$(cat \"$dotest/apply-opt\")\n+EXTRA_SIGNOFFS=\n+for ack in \"${signoffs[@]}\"; do\n+\tif test \"$EXTRA_SIGNOFFS\"\n+\tthen\n+\t\tEXTRA_SIGNOFFS=$(printf \"%s\\n%s\" \"$SIGNOFF\" \"$ack\")\n+\telse\n+\t\tEXTRA_SIGNOFFS=\"$ack\"\n+\tfi\n+done\n+\n if test \"$(cat \"$dotest/sign\")\" = t\n then\n \tSIGNOFF=$(git var GIT_COMMITTER_IDENT | sed -e '\n@@ -744,13 +762,13 @@ To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n \t\t    \"$dotest/msg-clean\" |\n \t\t    sed -ne '$p'\n \t\t)\n-\t\tADD_SIGNOFF=$(\n+\t\tADD_SIGNOFF=\"$EXTRA_SIGNOFFS\"$(\n \t\t    test \"$LAST_SIGNED_OFF_BY\" = \"$SIGNOFF\" || {\n \t\t    test '' = \"$LAST_SIGNED_OFF_BY\" && echo\n \t\t    echo \"$SIGNOFF\"\n \t\t})\n \t    else\n-\t\tADD_SIGNOFF=\n+\t\tADD_SIGNOFF=\"$EXTRA_SIGNOFFS\"\n \t    fi\n \t    {\n \t\tif test -s \"$dotest/msg-clean\"\n-- \nMST\n"}]}