Re: [PATCH 1/2] Allow users to require source branch on git-checkout -b.

2 messages, 2 authors, 2016-08-11 · open the first message on its own page

Re: [PATCH 1/2] Allow users to require source branch on git-checkout -b.

From: Junio C Hamano <hidden>
Date: 2016-08-11 19:19:13

"Shawn O. Pearce" [off-list ref] writes:
I have recently observed a rather large number of users who forget
to specify the base revision when they start a new branch with
git-checkout -b.  Many of these users are shocked many hours and
commits later when their prior branch is now also part of the new
branch.  Nasty words about Git usually follow the discovery.

This introduces a new config option: checkout.requireSourceBranch,
I'm not sure about this.

Often after you started to code something while on 'master' you
realize that work is not trivial and needs its own branch and
then "checkout -b" without having to say 'master' (or HEAD) is
very handy.

I think requring an explicit fork-point when you are _not_ on
'master' might be a better behaviour.

In other words, you allow "checkout -b" (and "branch") to
default to HEAD only while on the branches marked in your
configuration file:

Then:

	[branch]
        	allowbranchbydefault = main
        	allowbranchbydefault = test

can be used to say "while on 'main' and 'test' branch, 'git
checkout -b' and 'git branch' without branch point defaults to
the current branch".

You could turn it around and make it a per-branch configuration,
like:

	[branch "main"]
        	allowbranchbydefault = true

Re: [PATCH 1/2] Allow users to require source branch on git-checkout -b.

From: Shawn Pearce <hidden>
Date: 2016-08-11 20:20:12

Junio C Hamano [off-list ref] wrote:
"Shawn O. Pearce" [off-list ref] writes:
quoted
This introduces a new config option: checkout.requireSourceBranch,
You could turn it around and make it a per-branch configuration,
like:

	[branch "main"]
        	allowbranchbydefault = true
Are you suggesting that we change "git-checkout -b" to by default
require the source branch, but the user can restore the original
behavior by setting the above per-branch configuration option?

I'm OK with that version too.  Most of these users want to be
required to enter the source branch, and their topic branches (which
are always their current branches btw) are so transient they won't
bother with a per-branch setting.  So they get what they want:
the tool reminding them to select their source revision.

-- 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help