]>
Commit | Line | Data |
---|---|---|
a3e870f2 | 1 | #!/bin/sh |
9c065315 | 2 | : ${GIT_DIR=.git} |
96069cf0 LT |
3 | if [ ! -d $GIT_DIR ]; then |
4 | echo Not a git directory 1>&2 | |
5 | exit 1 | |
6 | fi | |
07954953 | 7 | git-update-cache -q --refresh -- "$@" || exit 1 |
96069cf0 LT |
8 | PARENTS="-p HEAD" |
9 | if [ ! -r $GIT_DIR/HEAD ]; then | |
10 | if [ -z "$(git-ls-files)" ]; then | |
11 | echo Nothing to commit 1>&2 | |
12 | exit 1 | |
13 | fi | |
14 | ( | |
15 | echo "#" | |
16 | echo "# Initial commit" | |
17 | echo "#" | |
18 | git-ls-files | sed 's/^/# New file: /' | |
19 | echo "#" | |
20 | ) > .editmsg | |
21 | PARENTS="" | |
22 | else | |
23 | if [ -f $GIT_DIR/MERGE_HEAD ]; then | |
24 | echo "#" | |
25 | echo "# It looks like your may be committing a MERGE." | |
26 | echo "# If this is not correct, please remove the file" | |
27 | echo "# $GIT_DIR/MERGE_HEAD" | |
28 | echo "# and try again" | |
29 | echo "#" | |
30 | PARENTS="-p HEAD -p MERGE_HEAD" | |
31 | fi > .editmsg | |
32 | git-status-script >> .editmsg | |
33 | fi | |
a3e870f2 LT |
34 | if [ "$?" != "0" ] |
35 | then | |
36 | cat .editmsg | |
170241b7 | 37 | rm .editmsg |
a3e870f2 LT |
38 | exit 1 |
39 | fi | |
2036d841 | 40 | ${VISUAL:-${EDITOR:-vi}} .editmsg |
a3e870f2 | 41 | grep -v '^#' < .editmsg | git-stripspace > .cmitmsg |
170241b7 LT |
42 | [ -s .cmitmsg ] && |
43 | tree=$(git-write-tree) && | |
44 | commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) && | |
45 | echo $commit > $GIT_DIR/HEAD && | |
46 | rm -f -- $GIT_DIR/MERGE_HEAD | |
47 | ret="$?" | |
48 | rm -f .cmitmsg .editmsg | |
49 | exit "$ret" |