#!/bin/bash
set -e

grep -q hooksPath ~/.gitconfig || { echo "missing hooksPath in .gitconfig"; exit 1; }

git init
echo "#!/bin/bash" > .git/hooks/post-commit
chmod +x .git/hooks/post-commit

for((i=0; i<10; i++)); do
	echo line1 > file$i
done
git add file*
git commit -m "initial commit"

for((i=0; i<10; i++)); do
	echo line2 >> file$i
done
git add file*
strace -f -o git-commit.strace -v -- git commit -m "commit"

for((i=0; i<10; i++)); do
	echo line3 >> file$i
done
git add file*
strace -f -o git-gui.strace -v -- git gui

echo
grep --color post- git-commit.strace
echo
grep --color post- git-gui.strace

echo
grep post- git-commit.strace | grep --color GIT_DIR || echo "!!! missing GIT_DIR in git-commit.strace"
echo
grep post- git-gui.strace | grep --color GIT_DIR || echo "!!! missing GIT_DIR in git-gui.strace"
