summaryrefslogtreecommitdiff
path: root/devtools/editcomment
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-03-23 09:13:40 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-03-23 09:13:40 -0400
commit8fd8e6abcb70b21c5ee861c843edad9d06d14010 (patch)
treeb91dd77dd836c6b515e16eda5004ff935c6e7d8e /devtools/editcomment
parent16fd0b73408faef2e06353f2a4a481e2c404ce32 (diff)
downloadgpsd-8fd8e6abcb70b21c5ee861c843edad9d06d14010.tar.gz
Add a utility for patching the comments in local commits.
Diffstat (limited to 'devtools/editcomment')
-rwxr-xr-xdevtools/editcomment37
1 files changed, 37 insertions, 0 deletions
diff --git a/devtools/editcomment b/devtools/editcomment
new file mode 100755
index 00000000..ff38d3c0
--- /dev/null
+++ b/devtools/editcomment
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Give this a commit-ID specification. It will edit the associated comment.
+# Usual caveats apply; the edited one and all commits after will change IDs,
+# and pushing them to a repo with the old commits will wreak havoc.
+# Note also that this cavalierly overwrites refs/original.
+
+topdir=`git rev-parse --show-cdup`
+test -n "$topdir" && cd "$topdir"
+
+my_file=COMMIT_EDITMSG
+test -d .git && myfile=.git/COMMIT_EDITMSG
+
+# This effort to invoke the user's normal editor fails.
+# the problem is that anytjing the editor writes to stdout on the
+# controlling terminal becomes part of the commit message. So
+# the editor needs to actually run inside another window.
+#test -z "$GIT_EDITOR" && GIT_EDITOR=$EDITOR
+#test -z "$GIT_EDITOR" && GIT_EDITOR=vi
+#my_editor=$GIT_EDITOR
+
+# xterm -e vi should also work.
+my_editor=emacsclient
+
+my_commit=`git rev-parse $1` || exit $?
+
+export my_file my_commit my_editor
+
+exec git filter-branch -f --msg-filter '
+if test "$GIT_COMMIT" = "$my_commit"; then
+ cat > $my_file;
+ $my_editor $my_file >/dev/null;
+ cat $my_file
+else
+ cat
+fi' "$1~.."
+
+# End