sha1: Formatting the output as the test cases expect.
[guilt/mob.git] / guilt-branch
blobf81adb2c665dc8f89be687a5ed3517b9c57c316b
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007-2008
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 cat "$applied" | while read n; do
29 git update-ref "refs/patches/$newbranch/$n" \
30 `git rev-parse "refs/patches/$branch/$n"` ""
31 done
33 git branch "$newbranch"
34 git checkout "$newbranch"
36 mkdir -p "$GUILT_DIR/`dirname $newbranch`"
38 # copy the patch dir
39 case $UNAME_S in
40 # Darwin doesn't have the GNU equalient -d (--no-dereference --preserve=links),
41 # flags
42 Darwin) cp -p "$GUILT_DIR/$branch" "$GUILT_DIR/$newbranch" ;;
43 Linux) cp -a "$GUILT_DIR/$branch" "$GUILT_DIR/$newbranch" ;;
44 *) echo "Unsupported operating system: $UNAME_S" ;;
45 esac
47 # copy the refs