git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] git-am: support any number of signatures
@ 2014-06-12 16:12 Michael S. Tsirkin
  2014-06-12 19:07 ` Junio C Hamano
  2014-06-12 19:25 ` René Scharfe
  0 siblings, 2 replies; 31+ messages in thread
From: Michael S. Tsirkin @ 2014-06-12 16:12 UTC (permalink / raw)
  To: git

I'm using different signature tags for git am depending on the patch,
project and other factors.

Sometimes I add multiple tags as well, e.g. QEMU
wants both Reviewed-by and Signed-off-by tags.

This patch makes it easy to do so:
1.  new parameter am.signoff can be used any number
	of times:

[am]
	signoff = "Reviewed-by: Michael S. Tsirkin <mst@redhat.com>"
	signoff = "Signed-off-by: Michael S. Tsirkin <mst@redhat.com>"

	if set all signatures are picked up when git am -s is used.

2.  Any number of alternative signatures

[am "a"]
	signoff = "Acked-by: Michael S. Tsirkin <mst@redhat.com>"

	if set the signature type can be specified by passing
	a parameter to the -s flag:

	git am -sa

No docs or tests, sorry, so not yet ready for master, but I'm using this
all the time without any issues so maybe ok for pu.
Early flames/feedback/help welcome.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 git-am.sh | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index ee61a77..e992c34 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -13,7 +13,7 @@ i,interactive   run interactively
 b,binary*       (historical option -- no-op)
 3,3way          allow fall back on 3way merging if needed
 q,quiet         be quiet
-s,signoff       add a Signed-off-by line to the commit message
+s,signoff?      add a Signed-off-by line to the commit message
 u,utf8          recode into utf8 (default)
 k,keep          pass -k flag to git-mailinfo
 keep-non-patch  pass -b flag to git-mailinfo
@@ -136,7 +136,7 @@ fall_back_3way () {
     eval "$cmd" &&
     GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
     git write-tree >"$dotest/patch-merge-base+" ||
-    cannot_fallback "$(gettext "Repository lacks necessary blobs to fall back on 3-way merge.")"
+    cannot_fallback "$(gettext "Repository lsignoffs necessary blobs to fall back on 3-way merge.")"
 
     say "$(gettext "Using index info to reconstruct a base tree...")"
 
@@ -383,6 +383,7 @@ then
     keepcr=t
 fi
 
+signoffs=
 while test $# != 0
 do
 	case "$1" in
@@ -394,8 +395,15 @@ it will be removed. Please do not use it anymore."
 		;;
 	-3|--3way)
 		threeway=t ;;
-	-s|--signoff)
-		sign=t ;;
+	--signoff)
+		sign=t
+		s=$(git config --get-all am.signoff)
+		signoffs=("${signoffs[@]}" "${s[@]}") ;;
+	--signoff=*)
+		sign=t
+		a="${1#--signoff=}"
+		s=$(git config --get-all am."${a}".signoff)
+		signoffs=("${signoffs[@]}" "${s[@]}") ;;
 	-u|--utf8)
 		utf8=t ;; # this is now default
 	--no-utf8)
@@ -644,14 +652,25 @@ fi
 git_apply_opt=$(cat "$dotest/apply-opt")
 if test "$(cat "$dotest/sign")" = t
 then
-	SIGNOFF=$(git var GIT_COMMITTER_IDENT | sed -e '
-			s/>.*/>/
-			s/^/Signed-off-by: /'
-		)
+	for ack in "${signoffs[@]}"; do
+		if test "$SIGNOFF"
+		then
+			SIGNOFF="$SIGNOFF\n$ack"
+		else
+			SIGNOFF="$ack"
+		fi
+	done
+	if test -z "$SIGNOFF"
+	then
+		SIGNOFF=$(git var GIT_COMMITTER_IDENT | sed -e '
+				s/>.*/>/
+				s/^/Signed-off-by: /'
+			)
+	fi
 else
 	SIGNOFF=
 fi
 
 last=$(cat "$dotest/last")
 this=$(cat "$dotest/next")
 if test "$skip" = t
-- 
MST

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2014-10-14  5:29 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-12 16:12 [PATCH RFC] git-am: support any number of signatures Michael S. Tsirkin
2014-06-12 19:07 ` Junio C Hamano
2014-06-13  8:00   ` Michael S. Tsirkin
2014-06-13 17:32     ` Junio C Hamano
2014-06-15 10:27       ` Michael S. Tsirkin
2014-06-16 18:06         ` Junio C Hamano
2014-06-18  3:09           ` Michael S. Tsirkin
2014-06-18  6:49             ` Junio C Hamano
2014-06-18  7:33               ` Michael S. Tsirkin
2014-06-18 17:51               ` Junio C Hamano
2014-06-18 18:23                 ` Michael S. Tsirkin
2014-09-22 14:01                 ` Michael S. Tsirkin
2014-09-22 17:58                   ` Junio C Hamano
2014-09-23  7:45                   ` Christian Couder
2014-09-23  8:07                     ` Michael S. Tsirkin
2014-09-24 10:00                       ` Christian Couder
2014-10-07 21:33                         ` Michael S. Tsirkin
2014-09-23 17:15                     ` Junio C Hamano
2014-09-25  5:04                       ` Junio C Hamano
2014-09-25 10:04                       ` Christian Couder
2014-09-25 16:20                         ` Junio C Hamano
2014-09-28 11:36                           ` Christian Couder
     [not found]                             ` <7viok7k0c0.fsf@alter.siamese.dyndns.org>
2014-10-12  9:36                               ` Christian Couder
2014-10-13  5:09                                 ` Christian Couder
2014-10-13 22:05                                   ` Junio C Hamano
2014-10-14  5:29                                     ` Christian Couder
2014-10-07 21:29                       ` Michael S. Tsirkin
2014-10-07 21:39                         ` Jeff King
2014-10-07 21:41                           ` Junio C Hamano
2014-06-12 19:25 ` René Scharfe
2014-06-13  8:01   ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).