summaryrefslogtreecommitdiff
path: root/bin/git-branchmove
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-05-03 14:01:01 -0700
committerSean Whitton <spwhitton@spwhitton.name>2019-05-03 14:04:36 -0700
commite0830b3247541071d867fa34b5635e552d8dff58 (patch)
tree4a34d3605cf6b9c90653afdb1b1de41c76fdc282 /bin/git-branchmove
parent8d1573143fcaa5dd814e3ab2fabdd34167145aae (diff)
downloaddotfiles-e0830b3247541071d867fa34b5635e552d8dff58.tar.gz
git-branchmove: factor out $named_remote
Diffstat (limited to 'bin/git-branchmove')
-rwxr-xr-xbin/git-branchmove5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/git-branchmove b/bin/git-branchmove
index 0b928285..dc35a0a9 100755
--- a/bin/git-branchmove
+++ b/bin/git-branchmove
@@ -86,6 +86,9 @@ my ($op, $remote, @patterns) = @ARGV;
die "git-branchmove: unknown operation\n"
unless ($op eq 'get' or $op eq 'put');
+# is this a named remote or a git URL?
+my $named_remote = $remote =~ m|:| or $remote =~ m|^[/.]|;
+
# If we don't prefix the patterns, we might match branches the user
# doesn't intend. E.g. 'foo' would match 'wip/foo'
my @branch_pats = map { $_ =~ s|^|[r]efs/heads/|; $_ } @patterns;
@@ -155,7 +158,7 @@ if ($op eq 'put') {
# if the remote is a named remote, rather than just a URI, update
# remote-tracking branches
-unless ($remote =~ m|:| or $remote =~ m|^[/.]|) {
+unless ($named_remote) {
foreach my $source_branch (@source_branches) {
my $branch = $source_branch->{ref} =~ s|^refs/heads/||r;
my $tracking_ref = "refs/remotes/$remote/$branch";