-
Notifications
You must be signed in to change notification settings - Fork 10
/
pre-commit
executable file
·25 lines (25 loc) · 981 Bytes
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
git preserve-permissions --check --hook
return_code="$?"
if [ "${return_code}" != "0" ]; then
autosave=$(git config --bool --get preserve-permissions.autosave)
autosavePatch=$(git config --bool --get preserve-permissions.autosavePatch)
gpp_file=$(git config --get preserve-permissions.file)
[ -z "${autosave}" ] && autosave="true"
[ -z "${autosavePatch}" ] && autosavePatch="false"
[ -z "${gpp_file}" ] && gpp_file=".git-preserve-permissions"
if [ "${autosave}" = "false" ]; then
echo "Execute 'git preserve-permissions --save' to save new permissions"
echo "Then 'git add ${gpp_file}' and redo your commit"
elif [ "${autosavePatch}" = "true" ]; then
git preserve-permissions --save --hook
exec < /dev/tty
git add -p "${gpp_file}"
return_code=$?
else
git preserve-permissions --save --hook
git add "${gpp_file}"
return_code=$?
fi
exit ${return_code}
fi