All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rubén Justo" <rjusto@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 1/2] add-patch: introduce 'p' in interactive-patch
Date: Tue, 26 Mar 2024 00:15:51 +0100	[thread overview]
Message-ID: <8dc0218b-914d-4a12-8136-45c6d62162a6@gmail.com> (raw)
In-Reply-To: <xmqqcyrigfft.fsf@gitster.g>

On Mon, Mar 25, 2024 at 02:38:30PM -0700, Junio C Hamano wrote:
> Rubén Justo <rjusto@gmail.com> writes:
> 
> > Shortly we're going make interactive-patch stop printing automatically
> > the hunk under certain circumstances.
> >
> > Let's introduce a new option to allow the user to explicitly request
> > the printing.
> 
> That is good, but ...
> 
> > Signed-off-by: Rubén Justo <rjusto@gmail.com>
> > ---
> >  add-patch.c                |  4 ++++
> >  t/t3701-add-interactive.sh | 22 +++++++++++-----------
> >  2 files changed, 15 insertions(+), 11 deletions(-)
> >
> > diff --git a/add-patch.c b/add-patch.c
> > index 68f525b35c..52be1ddb15 100644
> > --- a/add-patch.c
> > +++ b/add-patch.c
> > @@ -1388,6 +1388,7 @@ N_("j - leave this hunk undecided, see next undecided hunk\n"
> >     "/ - search for a hunk matching the given regex\n"
> >     "s - split the current hunk into smaller hunks\n"
> >     "e - manually edit the current hunk\n"
> > +   "p - print again the current hunk\n"
> >     "? - print help\n");
> >  
> >  static int patch_update_file(struct add_p_state *s,
> > @@ -1480,6 +1481,7 @@ static int patch_update_file(struct add_p_state *s,
> >  				permitted |= ALLOW_EDIT;
> >  				strbuf_addstr(&s->buf, ",e");
> >  			}
> > +			strbuf_addstr(&s->buf, ",p");
> >  		}
> >  		if (file_diff->deleted)
> >  			prompt_mode_type = PROMPT_DELETION;
> > @@ -1658,6 +1660,8 @@ static int patch_update_file(struct add_p_state *s,
> >  				hunk->use = USE_HUNK;
> >  				goto soft_increment;
> >  			}
> > +		} else if (s->answer.buf[0] == 'p') {
> > +			/* nothing to do */
> 
> This is not good.  If we are taking a new input, why doesn't the
> code already respond to it?  "Showing it again" should be a separate
> feature even if some other codepaths still do show when [2/2] would
> prevent them to show, no?

Doing nothing here produces, in the current implementation, the intended
printing.  Maybe the message needs to state so?

> Also, in addition to the changes to the patch to unbreak it, we'd
> need to update the git-add(1) manual page, especially its section on
> the interactive mode.  I think a single-line addition should suffice,
> but it has to be there, added by the same patch as the one that
> starts accepting 'p' and acting on that input.

Oh, of course.  I think this is the line needed:

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 14a371fff3..90b47927b2 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -348,6 +348,7 @@ patch::
        K - leave this hunk undecided, see previous hunk
        s - split the current hunk into smaller hunks
        e - manually edit the current hunk
+       p - print again the current hunk
        ? - print help
 +
 After deciding the fate for all hunks, if there is any hunk

  reply	other threads:[~2024-03-25 23:15 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 20:59 [PATCH 0/2] improve interactive-patch Rubén Justo
2024-03-25 21:05 ` [PATCH 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-25 21:38   ` Junio C Hamano
2024-03-25 23:15     ` Rubén Justo [this message]
2024-03-25 23:42       ` Junio C Hamano
2024-03-25 21:07 ` [PATCH 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-25 21:34   ` Junio C Hamano
2024-03-26  0:15 ` [PATCH v2 0/2] improve interactive-patch Rubén Justo
2024-03-26  0:17   ` [PATCH v2 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-26 14:38     ` Phillip Wood
2024-03-26 18:40       ` Rubén Justo
2024-03-27 10:55         ` Phillip Wood
2024-03-26  0:17   ` [PATCH v2 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-26 14:39     ` Phillip Wood
2024-03-26 18:46       ` Rubén Justo
2024-03-27 11:06         ` Phillip Wood
2024-03-28  0:39           ` Rubén Justo
2024-03-26 14:37   ` [PATCH v2 0/2] improve interactive-patch Phillip Wood
2024-03-26 15:31     ` Junio C Hamano
2024-03-26 18:48       ` Rubén Justo
2024-03-26 19:13         ` Junio C Hamano
2024-03-26 20:26           ` Rubén Justo
2024-03-29 19:26           ` Rubén Justo
2024-03-29 19:48             ` Dragan Simic
2024-03-30 13:49               ` Rubén Justo
2024-03-30 17:06             ` Junio C Hamano
2024-03-27 11:14       ` Phillip Wood
2024-03-27 15:43         ` Junio C Hamano
2024-03-27 16:14           ` Phillip Wood
2024-03-28  1:03           ` Rubén Justo
2024-03-26 18:46     ` Rubén Justo
2024-03-28  1:10   ` [PATCH v3 " Rubén Justo
2024-03-28  1:12     ` [PATCH v3 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-28 14:45       ` Junio C Hamano
2024-03-28  1:12     ` [PATCH v3 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-28 14:46       ` Junio C Hamano
2024-03-29  3:49         ` Rubén Justo
2024-03-29  3:56     ` [PATCH v4 0/2] improve interactive-patch Rubén Justo
2024-03-29  3:58       ` [PATCH v4 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-29  3:58       ` [PATCH v4 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-29 10:41         ` phillip.wood123
2024-03-29 11:37           ` Rubén Justo

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

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

  git send-email \
    --in-reply-to=8dc0218b-914d-4a12-8136-45c6d62162a6@gmail.com \
    --to=rjusto@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.