diff options
Diffstat (limited to 'devtools/editcomment')
-rwxr-xr-x | devtools/editcomment | 37 |
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 |