mbox series

[v2,0/2] stash clear: added safety flag for stash clear subcommand

Message ID pull.1232.v2.git.1653286345.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series stash clear: added safety flag for stash clear subcommand | expand

Message

Johannes Schindelin via GitGitGadget May 23, 2022, 6:12 a.m. UTC
PLAN: Add a flag to git stash clear (-i|--interactive), which prompts the
user to confirm he indeed wants to clear the stash, otherwise it will abort.

I found it useful as a frequent stash clear user which means my terminal
always have it in recent commands, which could mean accidental erase of
work. This flag ensures accidental fires won't clear hard work :)

I also thought it would be better to do it opt in, to not change the way the
command works in prod, only add to it.

Changes since v1:

Removed temporarily the interactive flag from stash. introduced add-menu lib
to the project, which is simply the extracted code that responsible for
presenting the menu in the clean command, and made the clean command use it.

This change was made to allow stash to use interactive as well, with the
same style as git clean.

Before I continue the development, I would like to know what the community
think about this refactor.

Thanks!

Nadav Goldstein (2):
  add-menu: added add-menu to lib objects
  clean: refector to the interactive part of clean

 Makefile        |   1 +
 add-menu.c      | 353 +++++++++++++++++++++++++++++++++++++++++
 add-menu.h      |  55 +++++++
 builtin/clean.c | 413 ++----------------------------------------------
 4 files changed, 425 insertions(+), 397 deletions(-)
 create mode 100644 add-menu.c
 create mode 100644 add-menu.h


base-commit: e8005e4871f130c4e402ddca2032c111252f070a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1232%2Fnadav96%2Fclear-stash-prompt-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1232/nadav96/clear-stash-prompt-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1232

Range-diff vs v1:

 1:  5396a67b0ff < -:  ----------- stash: added safety flag for stash clear subcommand
 -:  ----------- > 1:  13bc75a2b05 add-menu: added add-menu to lib objects
 -:  ----------- > 2:  7271a285d18 clean: refector to the interactive part of clean

Comments

Derrick Stolee May 23, 2022, 7:33 p.m. UTC | #1
On 5/23/22 2:12 AM, Nadav Goldstein via GitGitGadget wrote:
> PLAN: Add a flag to git stash clear (-i|--interactive), which prompts the
> user to confirm he indeed wants to clear the stash, otherwise it will abort.
> 
> I found it useful as a frequent stash clear user which means my terminal
> always have it in recent commands, which could mean accidental erase of
> work. This flag ensures accidental fires won't clear hard work :)
> 
> I also thought it would be better to do it opt in, to not change the way the
> command works in prod, only add to it.
> 
> Changes since v1:

It looks like you completely changed your approach here. It's perfectly
fine to use the same PR and keep the Git mailing list thread intact.

However, it would be good to keep the cover letter and title up-to-date
with what you are submitting. (Now that you have multiple patches, GGG
will split the PR Title and Description into your cover letter message.)

What you actually implement is a refactor to make 'git clean's
interactive menu be implemented in libgit.a.

> Removed temporarily the interactive flag from stash. introduced add-menu lib
> to the project, which is simply the extracted code that responsible for
> presenting the menu in the clean command, and made the clean command use it.
> 
> This change was made to allow stash to use interactive as well, with the
> same style as git clean.

It is interesting that you'd model 'git stash -i' after 'git clean -i'
instead of something like 'git add -p'. It would be interesting to see
your intended 'git stash' menu based on this API before we commit to
the extraction.

Thanks,
-Stolee