c80322ad096f1c54bb039d8f4d40060a467d5552
[git-central.git] / server / post-receive-git-config
1 #!/bin/sh
2
3 while read oldrev newrev refname ; do
4         if [ "$refname" == "refs/heads/gitconfig" ] ; then
5                 config_hash=$(git ls-tree $newrev | grep config | grep -oP '\w{40}')
6                 if [[ "$config_hash" != "" ]] ; then
7                         git cat-file blob "$config_hash" | while read line ; do
8                                 key="${line%=*}"
9                                 value="${line#*=}"
10                                 git config "${key}" "${value}"
11                         done
12                 fi
13
14                 hooks_hash=$(git ls-tree $newrev | grep hooks | grep -oP '\w{40}')
15                 if [[ "$hooks_hash" != "" ]] ; then
16                         git ls-tree "$hooks_hash" | while read mode type file_hash file_name ; do
17                                 echo "Installing $file_name"
18                                 git cat-file blob "$file_hash" > "hooks/$file_name"
19                         done
20                 fi
21         fi
22 done
23