public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Michael J Gruber <git@drmicha•warpmail.net>
Cc: git@vger•kernel.org
Subject: Re: [RFC/PATCH 2/2] branch: allow -f with -m and -d
Date: Thu, 04 Dec 2014 11:13:31 -0800	[thread overview]
Message-ID: <xmqqh9xbtehw.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <7b1ae15228841d3eaed739e89295ec10a2be45fa.1417699299.git.git@drmicha.warpmail.net> (Michael J. Gruber's message of "Thu, 4 Dec 2014 14:26:45 +0100")

Michael J Gruber <git@drmicha•warpmail.net> writes:

> -f/--force is the standard way to force an action, and is used by branch
> for the recreation of existing branches, but not for deleting unmerged
> branches nor for renaming to an existing branch.
>
> Make "-m -f" equivalent to "-M" and "-d -f" equivalent to" -D", i.e.
> allow -f/--force to be used with -m/-d also.

I like that goal.  And I agree with your s/force_create/force/g
remark on the cover, too.



> Signed-off-by: Michael J Gruber <git@drmicha•warpmail.net>
> ---
>  builtin/branch.c  | 9 +++++++--
>  t/t3200-branch.sh | 5 +++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 3b79c50..8ea04d7 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -848,7 +848,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>  		OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")),
>  		OPT_BOOL(0, "edit-description", &edit_description,
>  			 N_("edit the description for the branch")),
> -		OPT__FORCE(&force_create, N_("force creation (when already exists)")),
> +		OPT__FORCE(&force_create, N_("force creation, move/rename, deletion")),
>  		{
>  			OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
>  			N_("commit"), N_("print only not merged branches"),
> @@ -891,7 +891,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>  	if (with_commit || merge_filter != NO_FILTER)
>  		list = 1;
>  
> -	if (!!delete + !!rename + !!force_create + !!new_upstream +
> +	if (!!delete + !!rename + !!new_upstream +

This puzzled me but earlier -f implied creation and no other mode
(hence it was an error to give it together with delete and other
modes), but now -f is merely a "do forcibly whatever mode of
operation other option determines" that does not conflict.

What should "-f -u" and "-f -l" do, then, though?

>  	    list + unset_upstream > 1)
>  		usage_with_options(builtin_branch_usage, options);
>  
> @@ -904,6 +904,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
>  		colopts = 0;
>  	}
>  
> +	if (force_create) {
> +		delete *= 2;
> +		rename *= 2;
> +	}
> +
>  	if (delete) {
>  		if (!argc)
>  			die(_("branch name required"));
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index 0b3b8f5..ddea498 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -106,6 +106,11 @@ test_expect_success 'git branch -M o/q o/p should work when o/p exists' '
>  	git branch -M o/q o/p
>  '
>  
> +test_expect_success 'git branch -m -f o/q o/p should work when o/p exists' '
> +	git branch o/q &&
> +	git branch -m -f o/q o/p
> +'
> +
>  test_expect_success 'git branch -m q r/q should fail when r exists' '
>  	git branch q &&
>  	git branch r &&

  reply	other threads:[~2014-12-04 19:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04 13:26 [RFC/PATCH 0/2] Make git branch -f forceful Michael J Gruber
2014-12-04 13:26 ` [RFC/PATCH 1/2] t3200-branch: test -M Michael J Gruber
2014-12-04 13:26 ` [RFC/PATCH 2/2] branch: allow -f with -m and -d Michael J Gruber
2014-12-04 19:13   ` Junio C Hamano [this message]
2014-12-05 10:57     ` Michael J Gruber
2014-12-05 18:02       ` Junio C Hamano
2014-12-08 16:28         ` [PATCHv2 0/2] Make git branch -f forceful Michael J Gruber
2014-12-08 16:28           ` [PATCHv2 1/2] t3200-branch: test -M Michael J Gruber
2014-12-08 16:28           ` [PATCHv2 2/2] branch: allow -f with -m and -d Michael J Gruber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh9xbtehw.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@drmicha$(echo .)warpmail.net \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox