Skip to content

Commit 2455ad6

Browse files
authored
Merge pull request #71 from unixorn/update-cut-branch
Update cut branch
2 parents 7a72369 + 9dd2804 commit 2455ad6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

bin/git-cut-branch

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
#
33
# https://github.com/rtomayko/dotfiles
44
#
@@ -37,7 +37,7 @@ sha=$(git rev-parse HEAD)
3737
die "you're not on a branch"
3838

3939
# just the branch name please
40-
current=$(echo "$ref" |sed 's@^refs/heads/@@')
40+
current=$(echo "$ref" | sed 's@^refs/heads/@@')
4141
[ -n "$current" ] ||
4242
die "you're in a weird place; get on a local branch"
4343

@@ -47,11 +47,12 @@ merge=$(git config --get "branch.$current.merge" | sed 's@refs/heads/@@')
4747

4848
# build up a sane <remote>/<branch> name
4949
# shellcheck disable=SC2166
50-
if [ -n "$remote" -a -n "$merge" ]
51-
then tracking="$remote/$merge"
52-
elif [ -n "$merge" ]
53-
then tracking="$merge"
54-
else die "$current is not tracking anything"
50+
if [ -n "$remote" -a -n "$merge" ]; then
51+
tracking="$remote/$merge"
52+
elif [ -n "$merge" ]; then
53+
tracking="$merge"
54+
else
55+
die "$current is not tracking anything"
5556
fi
5657

5758
# make sure there's no changes before we reset hard
@@ -64,7 +65,7 @@ fi
6465
git branch "$branch"
6566
git reset -q --hard "$tracking"
6667
git checkout -q "$branch"
67-
git branch --set-upstream "$branch" "$tracking"
68+
git branch --set-upstream-to "$branch" "$tracking"
6869
git reset -q --hard "$sha"
6970
# shellcheck disable=SC2086,SC2046
7071
echo "[$(shortsha "$sha")...$(shortsha $(git rev-parse $tracking))] $current"

0 commit comments

Comments
 (0)