chrootsetup_linux.sh: include libnss_files.so* in chroot
[girocco.git] / bin / create-initial-empty-commit
blob3e1ed02d50eaa04f436c690c4ef3f68c3719cda7
1 #!/bin/sh
3 set -e
5 . @basedir@/shlib.sh
7 [ -n "$defined_cfg_empty_commit_message" ] || exit 0 # nothing to do, not enabled
9 proj="$1"
10 [ -d "$cfg_reporoot/$proj.git" ] || { echo "Invalid project name: $1" >&2; exit 1; }
12 [ -f "$cfg_reporoot/$proj.git/.nofetch" ] || { echo "Mirrors do not create an initial empty commit: $1" >&2; exit 1; }
14 projdir="$cfg_reporoot/$proj.git"
16 [ -L "$projdir/HEAD" ] ||
17 ! [ -f "$projdir/HEAD" ] ||
18 ! [ -f "$projdir/config" ] ||
19 ! [ -f "$projdir/description" ] ||
20 ! [ -f "$projdir/hooks/pre-receive" ] ||
21 ! [ -x "$projdir/hooks/pre-receive" ] ||
22 ! [ -f "$projdir/hooks/post-receive" ] ||
23 ! [ -x "$projdir/hooks/post-receive" ] ||
24 ! [ -f "$projdir/hooks/update" ] ||
25 ! [ -x "$projdir/hooks/update" ] ||
26 ! [ -d "$projdir/objects" ] ||
27 ! [ -d "$projdir/info" ]
28 then
29 echo "Incorrectly set up project: $1" >&2
30 exit 1
33 umask $var_umask_perm
35 cd "$projdir" || { echo "Could not cd to project: $proj" >&2; exit 1; }
36 if symref="$(git symbolic-ref -q HEAD)" && ! git show-ref --verify -q "$symref"; then
37 # only do anything if HEAD is an unborn symbolic ref
38 mttree="$(git mktree </dev/null)" && [ -n "$mttree" ]
39 nowsecs="$(date +%s)" && [ -n "$nowsecs" ]
40 pnl=
41 [ -z "$cfg_empty_commit_message" ] || pnl='\n'
42 mtcommit="$(printf 'tree %s\nauthor - <-> %s +0000\ncommitter - <-> %s +0000\n\n%s'"$pnl" \
43 "$mttree" "$nowsecs" "$nowsecs" "$cfg_empty_commit_message" |
44 git hash-object -t commit -w --stdin)" && [ -n "$mtcommit" ]
45 git update-ref -m 'initial empty commit' HEAD "$mtcommit"
48 exit 0