git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Rubén Justo" <rjusto@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>,
	Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH v3 0/2] improve interactive-patch
Date: Thu, 28 Mar 2024 02:10:28 +0100	[thread overview]
Message-ID: <60d978d0-f69a-4b65-b4ba-d30dac8f112a@gmail.com> (raw)
In-Reply-To: <6f2ed406-2152-476b-b463-3010afe7e11e@gmail.com>

Let's reduce the verbosity in the interactive-patch process, in order to
make it less confusing.

Rubén Justo (2):
  add-patch: introduce 'p' in interactive-patch
  add-patch: do not print hunks repeatedly

 Documentation/git-add.txt  |  1 +
 add-patch.c                | 19 +++++++++++++++----
 t/t3701-add-interactive.sh | 22 +++++++++++-----------
 3 files changed, 27 insertions(+), 15 deletions(-)

Range-diff against v2:
1:  bbb3bbea1b ! 1:  ca2777cb12 add-patch: introduce 'p' in interactive-patch
    @@ Documentation/git-add.txt: 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
    ++       p - print the current hunk again
             ? - print help
      +
      After deciding the fate for all hunks, if there is any hunk
    @@ add-patch.c: 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"
    ++   "p - print the current hunk again\n"
         "? - print help\n");
      
      static int patch_update_file(struct add_p_state *s,
2:  4d5626e1c4 ! 2:  d7ad5e5424 add-patch: do not print hunks repeatedly
    @@ Commit message
         Signed-off-by: Rubén Justo <rjusto@gmail.com>
     
      ## add-patch.c ##
    -@@ add-patch.c: N_("j - leave this hunk undecided, see next undecided hunk\n"
    - static int patch_update_file(struct add_p_state *s,
    +@@ add-patch.c: static int patch_update_file(struct add_p_state *s,
      			     struct file_diff *file_diff)
      {
    --	size_t hunk_index = 0;
    -+	size_t hunk_index = 0, prev_hunk_index = -1;
    - 	ssize_t i, undecided_previous, undecided_next;
    + 	size_t hunk_index = 0;
    +-	ssize_t i, undecided_previous, undecided_next;
    ++	ssize_t i, undecided_previous, undecided_next, rendered_hunk_index = -1;
      	struct hunk *hunk;
      	char ch;
    + 	struct child_process cp = CHILD_PROCESS_INIT;
     @@ add-patch.c: static int patch_update_file(struct add_p_state *s,
      
      		strbuf_reset(&s->buf);
      		if (file_diff->hunk_nr) {
     -			render_hunk(s, hunk, 0, colored, &s->buf);
     -			fputs(s->buf.buf, stdout);
    -+			if (prev_hunk_index != hunk_index) {
    ++			if (rendered_hunk_index != hunk_index) {
     +				render_hunk(s, hunk, 0, colored, &s->buf);
     +				fputs(s->buf.buf, stdout);
    -+				strbuf_reset(&s->buf);
     +
    -+				prev_hunk_index = hunk_index;
    ++				rendered_hunk_index = hunk_index;
     +			}
      
    --			strbuf_reset(&s->buf);
    + 			strbuf_reset(&s->buf);
    ++
      			if (undecided_previous >= 0) {
      				permitted |= ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK;
      				strbuf_addstr(&s->buf, ",k");
    @@ add-patch.c: static int patch_update_file(struct add_p_state *s,
      				color_fprintf_ln(stdout, s->s.header_color,
      						 _("Split into %d hunks."),
      						 (int)splittable_into);
    -+				prev_hunk_index = -1;
    ++				rendered_hunk_index = -1;
     +			}
      		} else if (s->answer.buf[0] == 'e') {
      			if (!(permitted & ALLOW_EDIT))
    @@ add-patch.c: static int patch_update_file(struct add_p_state *s,
      			}
      		} else if (s->answer.buf[0] == 'p') {
     -			/* nothing special is needed */
    -+			prev_hunk_index = -1;
    ++			rendered_hunk_index = -1;
      		} else {
      			const char *p = _(help_patch_remainder), *eol = p;
      
-- 
2.44.0.370.gd7ad5e5424


  parent reply	other threads:[~2024-03-28  1:11 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
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   ` Rubén Justo [this message]
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

  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=60d978d0-f69a-4b65-b4ba-d30dac8f112a@gmail.com \
    --to=rjusto@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).