git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 2/7] built-in add -p: implement the "stash" and "reset" patch modes
Date: Tue, 17 Dec 2019 12:12:06 -0800	[thread overview]
Message-ID: <xmqqy2vag19l.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <846cf16e77f4af39310902129be40fda664ace72.1576579264.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Tue, 17 Dec 2019 10:40:59 +0000")

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The `git stash` and `git reset` commands support a `--patch` option, and
> both simply hand off to `git add -p` to perform that work. Let's teach
> the built-in version of that command to be able to perform that work, too.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  add-interactive.h |  2 ++
>  add-patch.c       | 85 ++++++++++++++++++++++++++++++++++++++++++++---
>  builtin/add.c     |  4 +++
>  3 files changed, 87 insertions(+), 4 deletions(-)
>
> 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.

> +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.

  reply	other threads:[~2019-12-17 20:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 10:40 [PATCH 0/7] stash/reset/checkout -p: optionally use the add --patch backend written in pure C Johannes Schindelin via GitGitGadget
2019-12-17 10:40 ` [PATCH 1/7] built-in add -p: prepare for patch modes other than "stage" Johannes Schindelin via GitGitGadget
2019-12-17 19:37   ` Junio C Hamano
2019-12-21 21:19     ` Johannes Schindelin
2019-12-17 10:40 ` [PATCH 2/7] built-in add -p: implement the "stash" and "reset" patch modes Johannes Schindelin via GitGitGadget
2019-12-17 20:12   ` Junio C Hamano [this message]
2019-12-21 21:23     ` Johannes Schindelin
2019-12-17 10:41 ` [PATCH 3/7] legacy stash -p: respect the add.interactive.usebuiltin setting Johannes Schindelin via GitGitGadget
2019-12-17 10:41 ` [PATCH 4/7] built-in stash: use the built-in `git add -p` if so configured Johannes Schindelin via GitGitGadget
2019-12-17 20:19   ` Junio C Hamano
2019-12-21 21:26     ` Johannes Schindelin
2019-12-17 10:41 ` [PATCH 5/7] built-in add -p: implement the "checkout" patch modes Johannes Schindelin via GitGitGadget
2019-12-17 10:41 ` [PATCH 6/7] built-in add -p: implement the "worktree" " Johannes Schindelin via GitGitGadget
2019-12-17 10:41 ` [PATCH 7/7] commit --interactive: make it work with the built-in `add -i` Johannes Schindelin via GitGitGadget
2019-12-17 20:23 ` [PATCH 0/7] stash/reset/checkout -p: optionally use the add --patch backend written in pure C Junio C Hamano
2019-12-21 21:57 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 1/7] built-in add -p: prepare for patch modes other than "stage" Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 2/7] built-in add -p: implement the "stash" and "reset" patch modes Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 3/7] legacy stash -p: respect the add.interactive.usebuiltin setting Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 4/7] built-in stash: use the built-in `git add -p` if so configured Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 5/7] built-in add -p: implement the "checkout" patch modes Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 6/7] built-in add -p: implement the "worktree" " Johannes Schindelin via GitGitGadget
2019-12-21 21:57   ` [PATCH v2 7/7] commit --interactive: make it work with the built-in `add -i` Johannes Schindelin via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy2vag19l.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).