summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-05-19 00:17:54 +0300
committerJunio C Hamano <gitster@pobox.com>2014-05-19 14:31:43 -0700
commit155e41004d2b22446387496a138e67c51cee8db6 (patch)
treed603fba95354a74aa60d5deee4ce11dffa4eb7d5
parentfb0e4df6ad40945a8af43dbe56d479990e1d4105 (diff)
downloadgit-mt/rebase-i-ack.tar.gz
git-ack: record an ackmt/rebase-i-ack
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xcontrib/git-ack84
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/git-ack b/contrib/git-ack
new file mode 100755
index 0000000000..4aeb16abd9
--- /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