aboutsummaryrefslogtreecommitdiffstats
path: root/git-init-shared
diff options
context:
space:
mode:
Diffstat (limited to 'git-init-shared')
-rwxr-xr-xgit-init-shared25
1 files changed, 25 insertions, 0 deletions
diff --git a/git-init-shared b/git-init-shared
new file mode 100755
index 0000000..ea18234
--- /dev/null
+++ b/git-init-shared
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -e
+
+usage() {
+ printf "usage: git init-shared directory [user...]\n" >&2
+ exit 1
+}
+
+add_to_acl() {
+ setfacl -m "d:u:$2:rwx" "$1"
+ setfacl -m "u:$2:rwx" "$1"
+}
+
+test $# -ge 1 || usage
+dir=$1
+shift
+
+mkdir "$dir"
+
+for user in "$(id -un)" "$@"; do
+ add_to_acl "$dir" "$user"
+done
+
+exec git init --bare "$dir"