Document that WebDAV doesn't need git on the server, and works over SSL
[4msysgit-hv.git] / t / t7505-prepare-commit-msg-hook.sh
blob802aa624d0ff6a1add2e1c7e40a651336b450053
1 #!/bin/sh
3 test_description='prepare-commit-msg hook'
5 . ./test-lib.sh
7 test_expect_success 'with no hook' '
9 echo "foo" > file &&
10 git add file &&
11 git commit -m "first"
15 # set up fake editor for interactive editing
16 cat > fake-editor <<'EOF'
17 #!/bin/sh
18 exit 0
19 EOF
20 chmod +x fake-editor
21 FAKE_EDITOR="$(pwd)/fake-editor"
22 export FAKE_EDITOR
24 # now install hook that always succeeds and adds a message
25 HOOKDIR="$(git rev-parse --git-dir)/hooks"
26 HOOK="$HOOKDIR/prepare-commit-msg"
27 mkdir -p "$HOOKDIR"
28 echo "#!$SHELL_PATH" > "$HOOK"
29 cat >> "$HOOK" <<'EOF'
31 if test "$2" = commit; then
32 source=$(git-rev-parse "$3")
33 else
34 source=${2-default}
36 if test "$GIT_EDITOR" = :; then
37 sed -e "1s/.*/$source (no editor)/" "$1" > msg.tmp
38 else
39 sed -e "1s/.*/$source/" "$1" > msg.tmp
41 mv msg.tmp "$1"
42 exit 0
43 EOF
44 chmod +x "$HOOK"
46 echo dummy template > "$(git rev-parse --git-dir)/template"
48 test_expect_success 'with hook (-m)' '
50 echo "more" >> file &&
51 git add file &&
52 git commit -m "more" &&
53 test "`git log -1 --pretty=format:%s`" = "message (no editor)"
57 test_expect_success 'with hook (-m editor)' '
59 echo "more" >> file &&
60 git add file &&
61 GIT_EDITOR="$FAKE_EDITOR" git commit -e -m "more more" &&
62 test "`git log -1 --pretty=format:%s`" = message
66 test_expect_success 'with hook (-t)' '
68 echo "more" >> file &&
69 git add file &&
70 git commit -t "$(git rev-parse --git-dir)/template" &&
71 test "`git log -1 --pretty=format:%s`" = template
75 test_expect_success 'with hook (-F)' '
77 echo "more" >> file &&
78 git add file &&
79 (echo more | git commit -F -) &&
80 test "`git log -1 --pretty=format:%s`" = "message (no editor)"
84 test_expect_success 'with hook (-F editor)' '
86 echo "more" >> file &&
87 git add file &&
88 (echo more more | GIT_EDITOR="$FAKE_EDITOR" git commit -e -F -) &&
89 test "`git log -1 --pretty=format:%s`" = message
93 test_expect_success 'with hook (-C)' '
95 head=`git rev-parse HEAD` &&
96 echo "more" >> file &&
97 git add file &&
98 git commit -C $head &&
99 test "`git log -1 --pretty=format:%s`" = "$head (no editor)"
103 test_expect_success 'with hook (editor)' '
105 echo "more more" >> file &&
106 git add file &&
107 GIT_EDITOR="$FAKE_EDITOR" git commit &&
108 test "`git log -1 --pretty=format:%s`" = default
112 test_expect_success 'with hook (--amend)' '
114 head=`git rev-parse HEAD` &&
115 echo "more" >> file &&
116 git add file &&
117 GIT_EDITOR="$FAKE_EDITOR" git commit --amend &&
118 test "`git log -1 --pretty=format:%s`" = "$head"
122 test_expect_success 'with hook (-c)' '
124 head=`git rev-parse HEAD` &&
125 echo "more" >> file &&
126 git add file &&
127 GIT_EDITOR="$FAKE_EDITOR" git commit -c $head &&
128 test "`git log -1 --pretty=format:%s`" = "$head"
132 cat > "$HOOK" <<'EOF'
133 #!/bin/sh
134 exit 1
137 test_expect_success 'with failing hook' '
139 head=`git rev-parse HEAD` &&
140 echo "more" >> file &&
141 git add file &&
142 ! GIT_EDITOR="$FAKE_EDITOR" git commit -c $head
146 test_expect_success 'with failing hook (--no-verify)' '
148 head=`git rev-parse HEAD` &&
149 echo "more" >> file &&
150 git add file &&
151 ! GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify -c $head
156 test_done