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

Re: [PATCH 2/7] built-in add -p: implement the "stash" and "reset" patch modes

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 21, 2019, 21:23 UTC
Message-ID
<nycvar.QRO.7.76.6.1912212221160.46@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqqy2vag19l.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Tue, 17 Dec 2019, Junio C Hamano wrote:
Show 17 quoted lines
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > diff --git a/add-interactive.h b/add-interactive.h
> > index 3defa2ff3d..c278f3e26f 100644
> > --- a/add-interactive.h
> > +++ b/add-interactive.h
> > @@ -25,6 +25,8 @@ int run_add_i(struct repository *r, const struct pathspec *ps);
> >
> >  enum add_p_mode {
> >  	ADD_P_STAGE,
> > +	ADD_P_STASH,
> > +	ADD_P_RESET,
>
> As I mentioned in my review on the previous step, ADD_P_ADD would be
> more descriptive of what is going on when listed together with STASH
> and RESET here.
I made the suggested change.
Show 49 quoted lines
> > +static struct patch_mode patch_mode_reset_head = {
> > +	.diff = { "diff-index", "--cached", NULL },
> > +	.apply = { "-R", "--cached", NULL },
> > +	.apply_check = { "-R", "--cached", NULL },
> > +	.is_reverse = 1,
> > +	.index_only = 1,
> > +	.prompt_mode = {
> > +		N_("Unstage mode change [y,n,q,a,d%s,?]? "),
> > +		N_("Unstage deletion [y,n,q,a,d%s,?]? "),
> > +		N_("Unstage this hunk [y,n,q,a,d%s,?]? "),
> > +	},
> > +	.edit_hunk_hint = N_("If the patch applies cleanly, the edited hunk "
> > +			     "will immediately be marked for unstaging."),
> > +	.help_patch_text =
> > +		N_("y - unstage this hunk\n"
> > +		   "n - do not unstage this hunk\n"
> > +		   "q - quit; do not unstage this hunk or any of the remaining "
> > +			"ones\n"
> > +		   "a - unstage this hunk and all later hunks in the file\n"
> > +		   "d - do not unstage this hunk or any of the later hunks in "
> > +			"the file\n"),
> > +};
> > +
> > +static struct patch_mode patch_mode_reset_nothead = {
> > +	.diff = { "diff-index", "-R", "--cached", NULL },
> > +	.apply = { "--cached", NULL },
> > +	.apply_check = { "--cached", NULL },
> > +	.is_reverse = 0,
> > +	.index_only = 1,
> > +	.prompt_mode = {
> > +		N_("Apply mode change to index [y,n,q,a,d%s,?]? "),
> > +		N_("Apply deletion to index [y,n,q,a,d%s,?]? "),
> > +		N_("Apply this hunk to index [y,n,q,a,d%s,?]? "),
> > +	},
> > +	.edit_hunk_hint = N_("If the patch applies cleanly, the edited hunk "
> > +			     "will immediately be marked for applying."),
> > +	.help_patch_text =
> > +		N_("y - apply this hunk to index\n"
> > +		   "n - do not apply this hunk to index\n"
> > +		   "q - quit; do not apply this hunk or any of the remaining "
> > +			"ones\n"
> > +		   "a - apply this hunk and all later hunks in the file\n"
> > +		   "d - do not apply this hunk or any of the later hunks in "
> > +			"the file\n"),
> > +};
>
> Interesting that "reset to HEAD" and "reset to non-HEAD" would have
> to swap the direction to make it feel more natural to the users.
> This is nothing new---just re-discovering that it is/was interesting.
Indeed. It matches the intuition, but looks incongruent.

Ciao, Dscho

Previous: Junio C HamanoNext: Johannes Schindelin via GitGitGadget
Message 8 of 23 in “stash/reset/checkout -p: optionally use the add --patch backend written in pure C”
  1. 0/7 stash/reset/checkout -p: optionally use the add --patch backend written in pure CJohannes Schindelin via GitGitGadget, Dec 17, 2019
  2. 3/7 legacy stash -p: respect the add.interactive.usebuiltin settingJohannes Schindelin via GitGitGadget, Dec 17, 2019
  3. 1/7 built-in add -p: prepare for patch modes other than "stage"Johannes Schindelin via GitGitGadget, Dec 17, 2019
  4. Junio C HamanoDec 17, 2019
  5. Johannes SchindelinDec 21, 2019
  6. 2/7 built-in add -p: implement the "stash" and "reset" patch modesJohannes Schindelin via GitGitGadget, Dec 17, 2019
  7. Junio C HamanoDec 17, 2019
  8. Johannes SchindelinDec 21, 2019
  9. 4/7 built-in stash: use the built-in `git add -p` if so configuredJohannes Schindelin via GitGitGadget, Dec 17, 2019
  10. Junio C HamanoDec 17, 2019
  11. Johannes SchindelinDec 21, 2019
  12. 5/7 built-in add -p: implement the "checkout" patch modesJohannes Schindelin via GitGitGadget, Dec 17, 2019
  13. 7/7 commit --interactive: make it work with the built-in `add -i`Johannes Schindelin via GitGitGadget, Dec 17, 2019
  14. 6/7 built-in add -p: implement the "worktree" patch modesJohannes Schindelin via GitGitGadget, Dec 17, 2019
  15. Junio C HamanoDec 17, 2019
  16. 0/7 stash/reset/checkout -p: optionally use the add --patch backend written in pure CJohannes Schindelin via GitGitGadget, Dec 21, 2019
  17. 1/7 built-in add -p: prepare for patch modes other than "stage"Johannes Schindelin via GitGitGadget, Dec 21, 2019
  18. 3/7 legacy stash -p: respect the add.interactive.usebuiltin settingJohannes Schindelin via GitGitGadget, Dec 21, 2019
  19. 2/7 built-in add -p: implement the "stash" and "reset" patch modesJohannes Schindelin via GitGitGadget, Dec 21, 2019
  20. 7/7 commit --interactive: make it work with the built-in `add -i`Johannes Schindelin via GitGitGadget, Dec 21, 2019
  21. 5/7 built-in add -p: implement the "checkout" patch modesJohannes Schindelin via GitGitGadget, Dec 21, 2019
  22. 4/7 built-in stash: use the built-in `git add -p` if so configuredJohannes Schindelin via GitGitGadget, Dec 21, 2019
  23. 6/7 built-in add -p: implement the "worktree" patch modesJohannes Schindelin via GitGitGadget, Dec 21, 2019

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.