git-am: support any number of signatures

Add new flag -a which can add any signature, and any number of them.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/git-am.sh b/git-am.sh
index ee61a77..16fb337 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -31,6 +31,7 @@
 patch-format=   format the patch(es) are in
 reject          pass it through git-apply
 resolvemsg=     override error message when patch failure occurs
+a,ack=          add an ack line to the commit message
 continue        continue applying patches after resolving a conflict
 r,resolved      synonyms for --continue
 skip            skip the current patch
@@ -377,6 +378,7 @@
 ignore_date=
 allow_rerere_autoupdate=
 gpg_sign_opt=
+SIGNOFF=
 
 if test "$(git config --bool --get am.keepcr)" = true
 then
@@ -418,6 +420,19 @@
 		rebasing=t threeway=t ;;
 	--resolvemsg=*)
 		resolvemsg="${1#--resolvemsg=}" ;;
+	-a|--ack)
+		shift
+		ack=$1
+		acks=`git config --get-all am.ack-$ack`
+		if test "acks"
+		then
+			if test "$SIGNOFF"
+			then
+				SIGNOFF=$SIGNOFF"
+"
+			fi
+			SIGNOFF=$SIGNOFF$acks
+		fi;;
 	--whitespace=*|--directory=*|--exclude=*|--include=*)
 		git_apply_opt="$git_apply_opt $(sq "$1")" ;;
 	-C*|-p*)
@@ -644,12 +659,14 @@
 git_apply_opt=$(cat "$dotest/apply-opt")
 if test "$(cat "$dotest/sign")" = t
 then
-	SIGNOFF=$(git var GIT_COMMITTER_IDENT | sed -e '
+	if test "$SIGNOFF"
+	then
+		SIGNOFF=$SIGNOFF"\n"
+	fi
+	SIGNOFF=$SIGNOFF$(git var GIT_COMMITTER_IDENT | sed -e '
 			s/>.*/>/
 			s/^/Signed-off-by: /'
 		)
-else
-	SIGNOFF=
 fi
 
 last=$(cat "$dotest/last")