chiark / gitweb /
a12cfa6dec2797d1e97f23b665951035ae9df09e
[topgit.git] / hooks / pre-commit.sh
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz>  2008
4 # GPLv2
5
6
7 ## Set up all the tg machinery
8
9 set -e
10 tg__include=1
11 tg_util() {
12         . "@bindir@"/tg
13 }
14 tg_util
15
16
17 ## Generally have fun
18
19 # Don't do anything on non-topgit branch
20 if head_=$(git symbolic-ref -q HEAD); then
21         case "$head_" in
22                 refs/heads/*)
23                         git rev-parse -q --verify "${head_/#refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
24                 *)
25                         exit 0;;
26         esac
27
28 else
29         exit 0;
30 fi
31
32 # TODO: check the index, not the working copy
33 [ -s "$root_dir/.topdeps" ] ||
34         die ".topdeps is missing"
35 [ -s "$root_dir/.topmsg" ] ||
36         die ".topmsg is missing"
37
38 # TODO: Verify .topdeps for valid branch names and against cycles