3 # Moves a branch to or from the current git tree to or from
6 # usage: git-branchmove get|put REMOTE BRANCH
11 fail () { echo >&2 "git-branchmove: $*"; exit 16; }
12 badusage () { fail "bad usage: $*"; }
25 badusage "wrong number of arguments or wrong operation"
30 # determine execute-sh runes for src and dst trees
31 # check that source branch is not checked out
32 # list affected branches on source
33 # list affected branches on destination and moan if any nonequal overlap
34 # transfer src->dst refs/heads/BRANCH:refs/heads/BRANCH
35 # transfer and merge reflog(s) xxx todo
39 *:*) remoteurl="$remote" ;;
41 git config remote."$remote".pushurl ||
42 git config remote."$remote".url ||
43 fail "no pushurl or url defined for remote $remote"
47 remote_spec="$(perl -e '
49 if (m#^ssh://([^:/]+)(?:\:(\w+))?#) {
53 } elsif (m#^([-+_.0-9a-zA-Z\@]+):(?!//)#) {
54 print "$'\''|ssh $1\n";
56 die "git-branchmove: unsupported remote url \`$_'\''\n";
60 remote_path="${remote_spec%%|*}"
61 remote_rune="${remote_spec#*|}"
65 src_rune="$remote_rune"
66 src_path="$remote_path"
71 dst_rune="$remote_rune"
72 dst_path="$remote_path"