jailsetup.sh: ensure safe.directory=* when running git
[girocco.git] / bin / create-private-area
blob4e66925a96b6b3730a532f60b1c94d091b2eb2cb
1 #!/bin/sh
3 set -e
5 . @basedir@/shlib.sh
7 proj="$1"
8 [ -d "$cfg_reporoot/$proj.git" ] || { echo "Invalid project name: $1" >&2; exit 1; }
10 projdir="$cfg_reporoot/$proj.git"
12 [ -L "$projdir/HEAD" ] ||
13 ! [ -f "$projdir/HEAD" ] ||
14 ! [ -f "$projdir/config" ] ||
15 ! [ -f "$projdir/description" ] ||
16 ! [ -d "$projdir/objects" ] ||
17 ! [ -d "$projdir/refs" ] ||
18 ! [ -d "$projdir/info" ]
19 then
20 echo "Incorrectly set up project: $1" >&2
21 exit 1
24 umask 002
26 mkdir -p "$projdir/private/refs"
27 chmod 02775 "$projdir/private" "$projdir/private/refs" ||
28 echo "Warning: could not chmod 02775 on all dirs" >&2
30 [ -e "$projdir/private/gc.pid" ] || printf '%s' '0 Private' >"$projdir/private/gc.pid"
31 [ -e "$projdir/private/objects" ] || ln -sfn ../objects "$projdir/private/objects"
32 [ -e "$projdir/private/config" ] || cat <<EOT >"$projdir/private/config"
33 [core]
34 repositoryFormatVersion = 0
35 filemode = true
36 bare = true
37 ignoreCase = false
38 sharedrepository = $cfg_git_shared_repository_setting
39 compression = 5
40 logAllRefUpdates = false
41 hooksPath = "$cfg_reporoot/_global/empty"
42 [extensions]
43 preciousObjects = true
44 [gc]
45 auto = 0
46 autoDetach = false
47 autoPackLimit = 0
48 packRefs = false
49 EOT
50 pcval="$(git --git-dir="$projdir" config --file "$projdir/config" --bool --get "core.precomposeunicode" 2>/dev/null)" || :
51 [ -z "$pcval" ] || git --git-dir="$projdir" config --file "$projdir/private/config" "core.precomposeunicode" "$pcval"
53 if [ ! -e "$projdir/private/HEAD" ]; then
54 printf '%s\n' "ref: refs/heads/{private}" >"$projdir/private/HEAD.$$"
55 mv -f "$projdir/private/HEAD.$$" "$projdir/private/HEAD"
56 rm -f "$projdir/private/HEAD.$$"
59 is_git_dir "$projdir/private" || {
60 echo "Unable to set up private area in project: $1" >&2
61 exit 1
64 exit 0