gitk: remove workaround for missing msgfmt
[4msysgit-hv.git] / t / t7503-pre-commit-hook.sh
blob96df218b0dced8e149f2e1f15d522e383376129c
1 #!/bin/sh
3 test_description='pre-commit 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 test_expect_success '--no-verify with no hook' '
17 echo "bar" > file &&
18 git add file &&
19 git commit --no-verify -m "bar"
23 # now install hook that always succeeds
24 HOOKDIR="$(git rev-parse --git-dir)/hooks"
25 HOOK="$HOOKDIR/pre-commit"
26 mkdir -p "$HOOKDIR"
27 cat > "$HOOK" <<EOF
28 #!/bin/sh
29 exit 0
30 EOF
31 chmod +x "$HOOK"
33 test_expect_success 'with succeeding hook' '
35 echo "more" >> file &&
36 git add file &&
37 git commit -m "more"
41 test_expect_success '--no-verify with succeeding hook' '
43 echo "even more" >> file &&
44 git add file &&
45 git commit --no-verify -m "even more"
49 # now a hook that fails
50 cat > "$HOOK" <<EOF
51 #!/bin/sh
52 exit 1
53 EOF
55 test_expect_success 'with failing hook' '
57 echo "another" >> file &&
58 git add file &&
59 test_must_fail git commit -m "another"
63 test_expect_success '--no-verify with failing hook' '
65 echo "stuff" >> file &&
66 git add file &&
67 git commit --no-verify -m "stuff"
71 chmod -x "$HOOK"
72 if test "$(git config --bool core.filemode)" = false; then
73 say "executable bit not honored - skipping tests of non-executable hook"
74 else
76 test_expect_success 'with non-executable hook' '
78 echo "content" >> file &&
79 git add file &&
80 git commit -m "content"
84 test_expect_success '--no-verify with non-executable hook' '
86 echo "more content" >> file &&
87 git add file &&
88 git commit --no-verify -m "more content"
92 fi # non-executable hooks
94 test_done