docs: handle `git describe` failing
[guilt.git] / guilt-branch
blob8876d44c26e515a7c5970b1e7c82b15336a5c228
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007
6 USAGE="[<new_name>]"
7 . `dirname $0`/guilt
9 if [ $# -gt 1 ]; then
10 usage
13 # make sure that there are no unapplied changes
14 if ! must_commit_first; then
15 die "Uncommited changes detected. Refresh first."
18 if [ $# -eq 0 ]; then
19 newbranch="$branch-`date +%Y-%m-%d`"
20 else
21 newbranch="$1"
24 if [ -e "$GUILT_DIR/$newbranch" ]; then
25 die "Patch directory for branch \"$newbranch\" already exists."
28 git branch "$newbranch"
29 git checkout "$newbranch"
31 mkdir -p "$GUILT_DIR/`dirname $newbranch`"
33 # copy the patch
34 cp -a "$GUILT_DIR/$branch" "$GUILT_DIR/$newbranch"