aboutsummaryrefslogtreecommitdiffstats
path: root/git-init-shared
blob: ea18234be710b02b44af73ea70d6a5fa5dd00d66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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"