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

Re: [PATCH v3] Introduced force flag to the git stash clear subcommand.

From
Nadav Goldstein <nadav.goldstein96@gmail.com>
Date
Jun 20, 2023, 19:54 UTC
Message-ID
<1540e884-08c7-922e-1fd9-65616268c1c9@gmail.com>
In-Reply-To
<xmqqy1keodjj.fsf@gitster.g>
Show 16 quoted lines
> I am not sure how much value users would get by requiring "--force",
> though.  I know this was (partly) modeled after "git clean", but
> over there, when the required "--force" is not given, the user would
> give "--dry-run" (or "-n"), and the user will see what would be
> removed if the user gave "--force".  If missing "--force" made "git
> stash clear" show the stash entries that would be lost, then after
> seeing an error message, it would be easier for the user to decide
> if their next move should be to re-run the command with "--force",
> or there are some precious entries and the user is not ready to do
> "stash clear".
>
> But just refusing to run without giving any other information will
> just train the user to give "git stash clear --force" without
> thinking, because getting "because you did not give the required
> --force option, I am not doing anything" is only annoying without
> giving any useful information.

I see, but isn't the same argument apply for git clean? if not adding the force flag, the same message as I wrote appear in git clean (I copied it from there), and it will exit without any other information, hence given your argument, running git clean is also not very useful.

One can argue that git clean --dry-run == git stash list

I suggested in the beginning of this thread to ask the user if he is sure he want to proceed (default to no), and only if he wrote y/yes proceed with the action (and force will just do it, or requireforce=false).

The reason I suggested it is because when running git stash clear, it will remain in the user recent commands, and when the user will navigate through the commands history in the terminal, he might accidentally fire git stash clear, and this confirmation will be another safeguard against this mistake.

Maybe it will be useful for git clean as well for the same reasons. Also when the user types git clean, I argue he wanted to clean or he did it by mistake, and In both scenarios I don't see why making git clean just fail will be useful.

So what do you think? Maybe we should present in both clean and clear a confirmation message? (only if requireforce=true)

What do you think?
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 15 in “stash: added safety flag for stash clear subcommand”
  1. stash: added safety flag for stash clear subcommandNadav Goldstein via GitGitGadget, May 15, 2022
  2. Junio C HamanoMay 16, 2022
  3. 0/2 stash clear: added safety flag for stash clear subcommandNadav Goldstein via GitGitGadget, May 23, 2022
  4. 1/2 add-menu: added add-menu to lib objectsNadav Goldstein via GitGitGadget, May 23, 2022
  5. Derrick StoleeMay 23, 2022
  6. Junio C HamanoMay 23, 2022
  7. 2/2 clean: refector to the interactive part of cleanNadav Goldstein via GitGitGadget, May 23, 2022
  8. Derrick StoleeMay 23, 2022
  9. Derrick StoleeMay 23, 2022
  10. Introduced force flag to the git stash clear subcommand.Nadav Goldstein via GitGitGadget, Jun 20, 2023
  11. Junio C HamanoJun 20, 2023
  12. Nadav GoldsteinJun 20, 2023
  13. Junio C HamanoJun 20, 2023
  14. Eric SunshineJun 20, 2023
  15. Nadav GoldsteinJun 20, 2023

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.