summaryrefslogtreecommitdiff
path: root/tools/git-setup
blob: 6f3c36f1cbfe9c9e48731e5aa99a9d20202de53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
cd "$(dirname -- "$0")"
cd "$(git rev-parse --show-toplevel)"

if [ -f .git/hooks/pre-commit.sample ] && [ ! -f .git/hooks/pre-commit ]; then
        # This part is allowed to fail
        cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
        chmod +x .git/hooks/pre-commit && \
        echo "Activated pre-commit hook." || :
fi

declare -A fetch
git config -f .gitconfig --get-regexp '.*' | while read -r key val; do
        if [[ $key = *.fetch ]]; then
                if [[ -z "${fetch[$key]}" ]]; then
                        git config --local --unset-all "$key"
                        fetch[$key]='true'
                fi
                git config --local --add "$key" "$val"
        else
                git config --local "$key" "$val"
        fi
done