blob: 3c1f9083df7361f149860415e437d0be0052ab70 [file] [log] [blame]
Vincent Driessen61ade552010-01-21 01:28:08 +01001#!/bin/sh
Vincent Driessen093a1472010-01-21 01:36:44 +01002#
3# gitflow -- A collection of Git wrapper scripts to provide high-level
4# repository operations for Vincent Driessen's branching model:
5#
6# Original blog post presenting this model is found at:
7# http://nvie.com/archives/323
8#
9# Feel free to contribute to this project at:
10# http://github.com/nvie/gitflow
11#
12# Copyright (c) 2010 by Vincent Driessen
13#
Vincent Driessen61ade552010-01-21 01:28:08 +010014
Vincent Driessen4f1cc332010-01-25 16:44:57 +010015# Get the git dir
16GIT_DIR=$(git rev-parse --git-dir)
17
18# Get all available branches
19LOCAL_BRANCHES=$(cd "$GIT_DIR/refs/heads"; find * -type f)
20REMOTE_BRANCHES=$(cd "$GIT_DIR/refs/remotes"; find * -type f)
21ALL_BRANCHES="$LOCAL_BRANCHES\n$REMOTE_BRANCHES"
22
23die() {
24 echo "$@" >&2
25 exit 1
26}
27
Vincent Driessen61ade552010-01-21 01:28:08 +010028gitflow_check_clean_working_tree() {
Vincent Driessen4f1cc332010-01-25 16:44:57 +010029 # TODO: Implement this
30 echo "TODO"
31}
32
33gitflow_require_local_branch() {
34 echo "$LOCAL_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null
35 if [ $? -ne 0 ]; then
36 die "Local branch '$1' does not exist and is required."
37 fi
38}
39
40gitflow_require_remote_branch() {
41 echo "$REMOTE_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null
42 if [ $? -ne 0 ]; then
43 die "Remote branch '$1' does not exist and is required."
44 fi
45}
46
47gitflow_require_branch() {
48 echo "$ALL_BRANCHES" | grep "^$1\$" 2>/dev/null >/dev/null
49 if [ $? -ne 0 ]; then
50 die "Branch '$1' does not exist and is required."
51 fi
Vincent Driessen61ade552010-01-21 01:28:08 +010052}
53