git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH 2/2] branch: allow -f with -m and -d

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Dec 5, 2014, 10:57 UTC
Message-ID
<54818FA7.7040102@drmicha.warpmail.net>
In-Reply-To
<xmqqh9xbtehw.fsf@gitster.dls.corp.google.com>
Junio C Hamano schrieb am 04.12.2014 um 20:13:
Show 50 quoted lines
> 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);
>>  

I would say there is nothing to force, so we ignore -f there. Alternatively, we could warn about that. While I do consider forcing something that doesn't need force a mistake in other contexts, I would not apply that thinking to the -f option.

Michael
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 9 in “Make git branch -f forceful”
  1. 0/2 Make git branch -f forcefulMichael J Gruber, Dec 4, 2014
  2. 1/2 t3200-branch: test -MMichael J Gruber, Dec 4, 2014
  3. 2/2 branch: allow -f with -m and -dMichael J Gruber, Dec 4, 2014
  4. Junio C HamanoDec 4, 2014
  5. Michael J GruberDec 5, 2014
  6. Junio C HamanoDec 5, 2014
  7. 0/2 Make git branch -f forcefulMichael J Gruber, Dec 8, 2014
  8. 1/2 t3200-branch: test -MMichael J Gruber, Dec 8, 2014
  9. 2/2 branch: allow -f with -m and -dMichael J Gruber, Dec 8, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.