All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: git@vger.kernel.org
Cc: bafain@gmail.com, sunshine@sunshineco.com
Subject: [PATCH 4/4] git-ack: record an ack
Date: Sun, 10 Apr 2016 16:54:52 +0300	[thread overview]
Message-ID: <1460296343-17304-5-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1460296343-17304-1-git-send-email-mst@redhat.com>

This is a simple script that I use by piping
incoming mail with an ack to it.
It produces an empty ack commit suitable for
squshing with git rebase -i -autosquash.

Works best if people ack individual commits: you simply
pipe each ack to git ack, before pushing your branch,
rebase.

Some people ack series by responding to cover letter
or to commit 1.
To address this usecase, there are two additional
flags: -s saves the ack signature in a file (you can
save several in a row), -r creates an ack for
a given patch using the saved signature.
Thus: pipe ack(s) to git ack -s, then select and pipe
each individual patch to git ack -r.

If it's found useful, this script can either
become a first-class command (with documentation
and tests) or be integrated as a flag into git am.

Limitations: requires that index is clean, this is
so we can create an empty commit recording the ack.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 contrib/git-ack | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100755 contrib/git-ack

diff --git a/contrib/git-ack b/contrib/git-ack
new file mode 100755
index 0000000..d8cba95
--- /dev/null
+++ b/contrib/git-ack
@@ -0,0 +1,91 @@
+msg=$(mktemp)
+patch=$(mktemp)
+info=$(git mailinfo $msg $patch)
+subj=$(echo "$info" | sed -n 's/^Subject: //p')
+#strip ack!/fixup!/squash! prefix
+subj=$(echo "$subj" | sed "s/^fixup![ 	]*//")
+subj=$(echo "$subj" | sed "s/^squash![ 	]*//")
+subj=$(echo "$subj" | sed "s/^ack![ 	]*//")
+author=$(echo "$info" | sed -n 's/^Author: //p')
+email=$(echo "$info" | sed -n 's/^Email: //p')
+auth="$author <$email>"
+date=$(echo "$info" | sed -n 's/^Date: //p')
+sign=$(mktemp)
+echo "ack! $subj" >"$sign"
+echo "" >> $sign
+if
+	git diff --exit-code --cached HEAD
+then
+	:
+else
+	echo "DIFF in cache. Not acked, reset or commit!"
+	exit 1
+fi
+GIT_DIR=$(git rev-parse --git-dir)
+
+usage () {
+	echo "Usage: git ack " \
+		"[-s|--save|-a|--append|-r|--restore |-c|--clear]\n" >&2;
+	exit 1;
+}
+
+append=
+save=
+clear=
+restore=
+
+while test $# != 0
+do
+	case "$1" in
+	-a|--append)
+		append="y"
+		;;
+	-s|--s)
+		save="y"
+		;;
+	-r|--restore)
+		restore="y"
+		;;
+	-c|--clear)
+		clear="y"
+		;;
+	*)
+		usage ;;
+	esac
+	shift
+done
+
+if
+	test "$clear"
+then
+	rm -f "${GIT_DIR}/ACKS"
+fi
+
+if
+	test "$save"
+then
+	if
+		test "$append"
+	then
+		cat $msg >>"${GIT_DIR}/ACKS"
+	else
+		cat $msg >"${GIT_DIR}/ACKS"
+	fi
+	exit 0
+fi
+
+if
+	test "$restore"
+then
+	msg=${GIT_DIR}/ACKS
+fi
+
+echo $msg > /dev/tty
+if
+	grep '^[A-Z][A-Za-z-]*-by:' $msg >> $sign
+then
+	git commit --allow-empty -F $sign --author="$auth" --date="$date"
+else
+	echo "No signature found!"
+	exit 2
+fi
-- 
MST

  parent reply	other threads:[~2016-04-10 13:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-10 13:54 [PATCH 0/4] support for ack commits Michael S. Tsirkin
2016-04-10 13:54 ` [PATCH 1/4] rebase -i: add ack action Michael S. Tsirkin
2016-04-11 11:02   ` Johannes Schindelin
2016-04-11 11:24     ` Michael S. Tsirkin
2016-04-11 15:36       ` Johannes Schindelin
2016-04-11 16:41         ` Michael S. Tsirkin
2016-04-11 19:48           ` Junio C Hamano
2016-04-11 19:55             ` Michael S. Tsirkin
2016-04-11 20:03               ` Matthieu Moy
2016-04-12  7:51                 ` Michael S. Tsirkin
2016-04-12 16:07                 ` Junio C Hamano
2016-04-12 16:33                   ` Michael S. Tsirkin
2016-04-12 20:00                     ` Junio C Hamano
2016-04-11 12:05     ` Christian Neukirchen
2016-04-10 13:54 ` [PATCH 2/4] git-rebase: document ack Michael S. Tsirkin
2016-04-10 13:54 ` [PATCH 3/4] rebase: test ack Michael S. Tsirkin
2016-04-10 13:54 ` Michael S. Tsirkin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-05-18 21:17 [PATCH 0/4] ack recoding in commit log Michael S. Tsirkin
2014-05-18 21:17 ` [PATCH 4/4] git-ack: record an ack Michael S. Tsirkin
2014-06-03 23:53   ` Fabian Ruch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460296343-17304-5-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=bafain@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.