-
Notifications
You must be signed in to change notification settings - Fork 0
/
guilt-branch
executable file
·56 lines (43 loc) · 1.07 KB
/
guilt-branch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007-2013
#
USAGE="[<new_name>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename "$0"` directly is no longer supported." >&2
exit 1
fi
if [ $# -gt 1 ]; then
usage
fi
_main() {
# make sure that there are no unapplied changes
if ! must_commit_first; then
die "Uncommited changes detected. Refresh first."
fi
if [ $# -eq 0 ]; then
newbranch="$branch-`date +%Y-%m-%d`"
else
newbranch="$1"
fi
if [ -e "$GUILT_DIR/$newbranch" ]; then
die "Patch directory for branch \"$newbranch\" already exists."
fi
cat "$applied" | while read n; do
git update-ref "refs/patches/$newbranch/$n" \
`git rev-parse "refs/patches/$branch/$n"` ""
done
if $old_style_prefix || [ -z "`get_top 2>/dev/null`" ]
then
newgitbranch="$newbranch"
else
git update-ref "refs/heads/$newbranch" "refs/heads/$branch" ""
newgitbranch="$GUILT_PREFIX$newbranch"
fi
git branch "$newgitbranch"
git checkout "$newgitbranch"
mkdir -p "$GUILT_DIR/`dirname $newbranch`"
# copy the patch dir
cp_a "$GUILT_DIR/$branch" "$GUILT_DIR/$newbranch"
# copy the refs
}