init: honor a global/system guilt.autotag config option
[guilt.git] / guilt-init
blob3089ac68c226398dfacafa1f8e2103993d93dab2
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006, 2007
6 DO_NOT_CHECK_BRANCH_EXISTENCE=1
8 USAGE="[-n | -a]"
9 . `dirname $0`/guilt
11 AUTOTAG_DEFAULT=1
13 while case $# in 0) break ;; esac; do
14 case $1 in
15 -n)
16 autotag=0
18 -a)
19 autotag=1
22 usage
24 esac
25 shift
26 done
28 if [ -d "$GUILT_DIR/$branch" ]; then
29 die "Branch $branch appears to be already initialized (GIT_DIR=$GIT_DIR)"
32 [ ! -d "$GUILT_DIR" ] && mkdir "$GUILT_DIR"
33 mkdir -p "$GUILT_DIR/$branch"
34 touch "$GUILT_DIR/$branch/series"
35 touch "$GUILT_DIR/$branch/status"
37 mkdir -p "$GIT_DIR/hooks/guilt"
38 cat > "$GIT_DIR/hooks/guilt/delete" <<EOF
39 #!/bin/sh
40 # Usage: <script> <patch being removed>
42 echo "Removing patch '\$1'..."
43 EOF
45 # if there's no guilt.autotag config, set it to default
46 cur=`git config --int --get guilt.autotag`
47 if [ -z "$cur" -o ! -z "$autotag" ]; then
48 [ -z "$autotag" ] && autotag=$AUTOTAG_DEFAULT
50 git config --int --replace-all guilt.autotag $autotag