summaryrefslogtreecommitdiff
path: root/tools/git-setup
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-08-17 20:19:57 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-08-17 20:19:57 -0400
commitf6fb0e626c492d854f21f3f91cefd288bd21d346 (patch)
treeeb0a3fcb6932b1d07a1598c2d9d9d607864cfc0c /tools/git-setup
parent50b1e92bb07c296befdaa3d0d9158882bd3e1146 (diff)
better git ref names
Diffstat (limited to 'tools/git-setup')
-rwxr-xr-xtools/git-setup23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/git-setup b/tools/git-setup
new file mode 100755
index 0000000000..6f3c36f1cb
--- /dev/null
+++ b/tools/git-setup
@@ -0,0 +1,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