git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] git-ack: record an ack

From
MTMichael S. Tsirkin <mst@redhat.com>
Date
May 18, 2014, 21:17 UTC
Message-ID
<1400447743-18513-5-git-send-email-mst@redhat.com>
In-Reply-To
<1400447743-18513-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.
I don't use these flags much so they likely work
less well.

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 | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100755 contrib/git-ack
diff --git a/contrib/git-ack b/contrib/git-ack
new file mode 100755
index 0000000..4aeb16a
--- /dev/null
+++ b/contrib/git-ack
@@ -0,0 +1,84 @@
+msg=`mktemp`
+patch=`mktemp`
+info=`git mailinfo $msg $patch`
+subj=`echo "$info"|sed -n 's/^Subject: //p'`
+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 --cached HEAD
+then
+    nop < /dev/null
+else
+    echo "DIFF in cache. Not acked, reset or commit!"
+    exit 1
+fi
+GIT_DIR=`pwd`/${GIT_DIR}
+
+usage () {
+	echo "Usage: git ack " \
+            "[-s|--save|-a|--append|-r|--restore |-c|--clear]\n" >& 2;
+        exit 1;
+}
+
+append=
+save=
+clear=
+
+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
+fi
+
+if
+    test "$restore"
+then
+    msg = ${GIT_DIR}/ACKS
+fi
+
+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
Previous: Junio C HamanoNext: Fabian Ruch
Message 14 of 17 in “ack recoding in commit log”
  1. 0/4 ack recoding in commit logMichael S. Tsirkin, May 18, 2014
  2. 1/4 rebase -i: add ack actionMichael S. Tsirkin, May 18, 2014
  3. 2/4 git-rebase: document ackMichael S. Tsirkin, May 18, 2014
  4. Eric SunshineMay 18, 2014
  5. 3/4 rebase: test ackMichael S. Tsirkin, May 18, 2014
  6. Junio C HamanoMay 19, 2014
  7. Michael S. TsirkinMay 19, 2014
  8. Michael S. TsirkinMay 20, 2014
  9. Junio C HamanoMay 20, 2014
  10. Michael S. TsirkinMay 21, 2014
  11. Junio C HamanoMay 21, 2014
  12. Michael S. TsirkinMay 21, 2014
  13. Junio C HamanoMay 21, 2014
  14. 4/4 git-ack: record an ackMichael S. Tsirkin, May 18, 2014
  15. Fabian RuchJun 3, 2014
  16. Fabian RuchJun 11, 2014
  17. Michael S. TsirkinJun 11, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.