blob: eae606078733baac4b6f83575311c2db4eaa7e7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/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.
#
# This script by Eric S. Raymond, March 2010, all rites perverted. It's based
# on an idea by thiago from #git, but debugged and with a safety check.
# It contains porcelain and porcelain byproducts.
topdir=`git rev-parse --show-cdup`
test -n "$topdir" && cd "$topdir"
my_commit=`git rev-parse $1` || exit $?
# Run a safety check before edits that could hose remotes.
if test -n "`git branch -r --contains $mycommit`"
then
echo -n "Commit has been pushed. Really edit? "
read yn
if test "$yn" != 'y'
then
exit 0
fi
fi
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 anything 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
export my_file my_commit my_editor
exec git filter-branch -f --tag-name-filter cat --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
|