From df06f3e3bd903abed2463b9ee307527b5c988d0c Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 3 Jul 2019 09:54:30 +0000 Subject: [PATCH] git-rename-branch: change branch argument order Now git-rename-branch has the same order like 'git branch -m', 'git rename-tag' and other rename command. Note that this is a break change. Close #759. --- Commands.md | 2 +- bin/git-rename-branch | 10 ++++++++-- man/git-rename-branch.1 | 14 +++++++------- man/git-rename-branch.html | 16 ++++++++-------- man/git-rename-branch.md | 12 ++++++------ 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Commands.md b/Commands.md index a4cb6b929..fc9671fd1 100644 --- a/Commands.md +++ b/Commands.md @@ -481,7 +481,7 @@ Rename a branch locally, and sync to remote via `git push`. ``` # renames any branch -$ git rename-branch new-name old-name +$ git rename-branch old-name new-name # renames current branch $ git rename-branch new-name diff --git a/bin/git-rename-branch b/bin/git-rename-branch index 9416d617f..93c8dbf2e 100755 --- a/bin/git-rename-branch +++ b/bin/git-rename-branch @@ -4,8 +4,14 @@ set -e # Assert there is at least one branch provided test -z $1 && echo "new branch name required." 1>&2 && exit 1 -new_branch="$1" -old_branch="${2-$(git symbolic-ref --short -q HEAD)}" +if [ -z $2 ]; then + new_branch="$1" + old_branch="$(git symbolic-ref --short -q HEAD)" +else + new_branch="$2" + old_branch="$1" +fi + remote=$(git config branch."$old_branch".remote; true) git branch -m "$old_branch" "$new_branch" diff --git a/man/git-rename-branch.1 b/man/git-rename-branch.1 index bb1df1ddd..8ada6b5a2 100644 --- a/man/git-rename-branch.1 +++ b/man/git-rename-branch.1 @@ -1,13 +1,13 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-RENAME\-BRANCH" "1" "October 2017" "" "Git Extras" +.TH "GIT\-RENAME\-BRANCH" "1" "July 2019" "" "Git Extras" . .SH "NAME" \fBgit\-rename\-branch\fR \- rename local branch and push to remote . .SH "SYNOPSIS" -\fBgit\-rename\-branch\fR +\fBgit\-rename\-branch\fR . .SH "DESCRIPTION" . @@ -21,13 +21,13 @@ Rename local branch and push the new branch to remote . .nf -<new\-branch> - -New branch name - <old\-branch> Old branch whose has to be renamed\. This is an optional parameter\. If no value is supplied then the current branch will be renamed\. + +<new\-branch> + +New branch name . .fi . @@ -35,7 +35,7 @@ Old branch whose has to be renamed\. This is an optional parameter\. If no value . .nf -$ git rename\-branch new\-name old\-name +$ git rename\-branch old\-name new\-name $ git rename\-branch new\-name . diff --git a/man/git-rename-branch.html b/man/git-rename-branch.html index ed1749352..f757aa4e4 100644 --- a/man/git-rename-branch.html +++ b/man/git-rename-branch.html @@ -76,7 +76,7 @@

NAME

SYNOPSIS

-

git-rename-branch <new-branch> <old-branch>

+

git-rename-branch <old-branch> <new-branch>

DESCRIPTION

@@ -85,25 +85,25 @@

DESCRIPTION

OPTIONS

-
&lt;new-branch&gt;
+
&lt;old-branch&gt;
 
-New branch name
+Old branch whose has to be renamed. This is an optional parameter. If no value is supplied then the current branch will be renamed.
 
-&lt;old-branch&gt;
+&lt;new-branch&gt;
 
-Old branch whose has to be renamed. This is an optional parameter. If no value is supplied then the current branch will be renamed.
+New branch name
 

EXAMPLES

-
$ git rename-branch new-name old-name
+
$ git rename-branch old-name new-name
 
 $ git rename-branch new-name
 

AUTHOR

-

Written by Hozefa Jodiawalla <hozefarules@gmail.com>

+

Written by Hozefa Jodiawalla <hozefarules@gmail.com>

REPORTING BUGS

@@ -116,7 +116,7 @@

SEE ALSO

  1. -
  2. October 2017
  3. +
  4. July 2019
  5. git-rename-branch(1)
diff --git a/man/git-rename-branch.md b/man/git-rename-branch.md index 17aba68b9..69e2d76f6 100644 --- a/man/git-rename-branch.md +++ b/man/git-rename-branch.md @@ -3,7 +3,7 @@ git-rename-branch(1) -- rename local branch and push to remote ## SYNOPSIS -`git-rename-branch` <new-branch> <old-branch> +`git-rename-branch` <old-branch> <new-branch> ## DESCRIPTION @@ -11,17 +11,17 @@ git-rename-branch(1) -- rename local branch and push to remote ## OPTIONS - <new-branch> - - New branch name - <old-branch> Old branch whose has to be renamed. This is an optional parameter. If no value is supplied then the current branch will be renamed. + <new-branch> + + New branch name + ## EXAMPLES - $ git rename-branch new-name old-name + $ git rename-branch old-name new-name $ git rename-branch new-name