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

Re: [PATCH] worktree: accept -f as short for --force for removal

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 18, 2018, 00:17 UTC
Message-ID
<xmqq4lk9l64o.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAPig+cTgoD-GvpoBQ6tcGX4T2XhuKccJAZ40P76vxVD_PfEc9A@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 28 quoted lines
> On Tue, Apr 17, 2018 at 2:19 PM, Stefan Beller <sbeller@google.com> wrote:
>> The force flag is very common in many commands and is commonly
>> abbreviated with '-f', so add that to worktree removal, too by using
>> OPT__FORCE instead of a self cooked OPT_BOOL for force.
>
> The missing bit of this sentence:
>
>     ...self cooked OPT_BOOL for force which forgets '-f'.
>
>> While at it, add the PARSE_OPT_NOCOMPLETE flag to the force command line
>> option as forcing a removal may lose files.
>>
>> The short form of "-f" is already documented in the man page,
>> so we do not have to adjust the docs.
>
> Makes sense. A possible rewrite (of the entire commit message):
>
>     worktree: remove: recognize -f as short for --force
>
>     Many commands support a --force option, frequently abbreviated as
>     -f, however, "git worktree remove"'s hand-rolled OPT_BOOL forgets
>     to recognize the short form, despite git-worktree.txt documenting
>     -f as supported. Replace OPT_BOOL with OPT__FORCE, which provides
>     -f for free, and makes 'remove' consistent with 'add' option
>     parsing (which also specifies the PARSE_OPT_NOCOMPLETE flag).
>
>> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
>> Signed-off-by: Stefan Beller <sbeller@google.com>

Looks better. I am not sure if s/--force/-f/ in the synopsis section is warranted, but '-f' is commonly understood as '--force' (and that is the point of this patch after all), so it is probably an improvement to be briefer.

Thanks, both.
Show 5 quoted lines
>
> The patch itself looks good. Thanks. With or without the above rewrite
> or minor adjustment, this patch is:
>
> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Previous: Eric SunshineNext: Eric Sunshine
Message 5 of 6 in “worktree: accept -f as short for --force for removal”
  1. worktree: accept -f as short for --force for removalStefan Beller, Apr 16, 2018
  2. Eric SunshineApr 17, 2018
  3. worktree: accept -f as short for --force for removalStefan Beller, Apr 17, 2018
  4. Eric SunshineApr 17, 2018
  5. Junio C HamanoApr 18, 2018
  6. Eric SunshineApr 18, 2018

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.