summaryrefslogtreecommitdiff
path: root/bin/vcsh-new
blob: f750bc320b9ebc242c4215e130a75724dac0014f (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
#
# vcsh-new
#
# Create a new vcs-home repository
#
# Copyright © 2009, 2010, 2013 Andreas Rottmann <a.rottmann@gmx.at>
# Released under the terms of the Artistic Licence 2.0
#

GITS_DIR="$HOME/.gits"

if [ "${1:---help}" = '--help' ] || [ $# -gt 2 ]; then
  echo "usage: ${0##*/} REPONAME [REPOS_LOCATION]" >&2
  [ "$1" = '--help' ]
  return $?
fi

repo="$1"
git_repos="$2"

if [ -d "$GITS_DIR/${repo}.git" ]; then
  echo E: repository "$repo" already exists >&2
  return 2
fi

mkdir -p "${GITS_DIR}"
export GIT_DIR="${GITS_DIR}/${repo}.git" 
git --bare init
cd "${GITS_DIR}/${repo}.git"
git config core.bare false
git config core.worktree ../../
git config core.excludesfile .var/"$repo"/gitignore
if [ -n "$git_repos" ]; then
    git remote add origin "${git_repos}/${repo}"
    git config branch.master.remote origin
    git config branch.master.merge master
fi