aboutsummaryrefslogtreecommitdiffstats
path: root/git-init-shared
diff options
context:
space:
mode:
authorWolfgang Müller2021-05-16 17:47:38 +0200
committerWolfgang Müller2021-05-16 17:50:29 +0200
commit6f3ea5c43096dd49a3b9d69566c97e70a31745ab (patch)
tree638ece03c8e14527f757c5127c05e7edbba6a4cd /git-init-shared
downloadgit-helpers-6f3ea5c43096dd49a3b9d69566c97e70a31745ab.tar.gz
Initial import
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"