initial version to check for staged changes
This commit is contained in:
commit
b8ff856fd8
19
pre-commit
Executable file
19
pre-commit
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# This also works
|
||||||
|
# $(git rev-parse --show-toplevel)/.git/hooks/pre-commit.sample
|
||||||
|
|
||||||
|
sample_hook="${PWD%"$GIT_PREFIX"}"/.git/hooks/pre-commit.sample
|
||||||
|
|
||||||
|
if test -x "$sample_hook"
|
||||||
|
then
|
||||||
|
$sample_hook
|
||||||
|
fi
|
||||||
|
|
||||||
|
current_dir=$(dirname "$0")
|
||||||
|
|
||||||
|
"$current_dir"/pre-commit-staged-check.sh
|
||||||
|
|
||||||
|
# vim: set ft=sh
|
14
pre-commit-staged-check.sh
Executable file
14
pre-commit-staged-check.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
case $GIT_INDEX_FILE in
|
||||||
|
*.lock)
|
||||||
|
if GIT_INDEX_FILE=${GIT_INDEX_FILE%.lock} git status --porcelain | grep '^M'
|
||||||
|
then
|
||||||
|
echo "Error: Found both staged and unstaged changes when trying to commit with 'git commit -a'."
|
||||||
|
echo "Do two seperate commits with, 'git commit -m ...' and 'git commit -a -m ...'"
|
||||||
|
echo "Or 'git reset .' and then 'git commit -a -m ...' for a single commit"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user