diff --git a/bin/git-create-branch b/bin/git-create-branch index 4e547d0..c94d0a0 100755 --- a/bin/git-create-branch +++ b/bin/git-create-branch @@ -1,10 +1,10 @@ #!/usr/bin/env bash +test $# -eq 0 && echo "branch argument required." 1>&2 && exit 1 + # preference takes lowest priority; look for remote from prefs first REMOTE_PREF=`git config git-extras.create-branch.remote` -if [ ${REMOTE_PREF} == "true" ]; then - REMOTE=origin -elif [ "$REMOTE_PREF" != ""]; then +if [ -n "$REMOTE_PREF" ]; then REMOTE=$REMOTE_PREF fi @@ -26,17 +26,22 @@ do shift done +# handle ambiguous `-r` option argument by shift if [[ -z $BRANCH ]] && [[ -n $REMOTE ]] then BRANCH=$REMOTE REMOTE=origin fi -test -z $BRANCH && echo "branch required." 1>&2 && exit 1 +test -z $BRANCH && echo "branch argument required." 1>&2 && exit 1 + if [[ -n $REMOTE ]] then git ls-remote --exit-code $REMOTE 1>/dev/null 2>/tmp/ls-remote-error - if [ $? = 0 ] + REMOTE_EXIT=$? + REMOTE_ERROR=$( -. -.br -Modified by Mark Pitman <\fImark\.pitman@gmail\.com\fR> +Written by Jonhnny Weslley <\fIjw@jonhnnyweslley\.net\fR> Modified by Mark Pitman <\fImark\.pitman@gmail\.com\fR>, Brian Murrell <\fIbtmurrell@gmail\.com\fR>\. . .SH "REPORTING BUGS" <\fIhttps://github\.com/tj/git\-extras/issues\fR> diff --git a/man/git-create-branch.html b/man/git-create-branch.html index d84dcfc..e0a054f 100644 --- a/man/git-create-branch.html +++ b/man/git-create-branch.html @@ -57,6 +57,7 @@ SYNOPSIS DESCRIPTION OPTIONS + PREFERENCES EXAMPLES NOTES AUTHOR @@ -81,35 +82,67 @@
Creates local branch named <branchname> and optionally sets up a remote tracking branch.
+Creates local branch named <branchname> and optionally sets up a remote tracking branch.
<-r|--remote [remote_name]>
+<-r|--remote [remote_name]>
- Setup a remote tracking branch using remote_name. If remote_name is not supplied, use origin by default.
Setup a remote tracking branch using remote_name. If remote_name is not supplied, use origin by default.
<branchname>
+<branchname>
-The name of the branch to create.
+The name of the branch to create.
+ +You may save your default preference for the remote option above by using git config with the key git-extras.create-branch.remote whose value will be the default remote when [-r|--remote] is not specified.
$ git config git-extras.create-branch.remote lucinda
+
+
+The command line option -r|--remote will override this preference.
$ git create-branch integration
+With no remote preference set:
+# creates local branch 'integration'
+$ git create-branch integration
+
+# creates local & remote branch 'integration' (on default 'origin')
$ git create-branch -r integration
+# creates local & remote branch 'integration' on 'upstream'
+$ git create-branch -r upstream integration
+
+
+With git-extras.create-branch.remote preference set to 'lucinda':
+
+# creates local & remote branch 'integration' (on preference 'lucinda')
+$ git create-branch integration
+
+# overriding preference, using default `-r` of 'origin'
+# creates local & remote branch 'integration' on default 'origin'
+$ git create-branch -r integration
+
+# overriding preference, using specified `-r` of 'upstream'
+# creates local & remote branch 'integration' on 'upstream'
$ git create-branch -r upstream integration
NOTES
-As of 4.4.0, the default behavior has changed. git-create-branch will no longer automatically setup a remote tracking branch unless the -r|-remote option is specified.
+
+As of 4.4.0, the default behavior has changed. git-create-branch will no longer automatically setup a remote tracking branch unless the -r|-remote option is specified. See additional note on preference feature in 4.8.0-dev below.
+As of 4.8.0-dev, the remote option can be set via git config preference as described in Preferences section.
+
+
AUTHOR
-Written by Jonhnny Weslley <jw@jonhnnyweslley.net>
-Modified by Mark Pitman <mark.pitman@gmail.com>
+Written by Jonhnny Weslley <jw@jonhnnyweslley.net>
+Modified by Mark Pitman <mark.pitman@gmail.com>, Brian Murrell <btmurrell@gmail.com>.
REPORTING BUGS
@@ -122,7 +155,7 @@ Modified by Mark Pitman <