From: phillip.wood123@gmail.com
To: "Rubén Justo" <rjusto@gmail.com>, "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: Re: [PATCH v4 2/2] add-patch: do not print hunks repeatedly
Date: Fri, 29 Mar 2024 10:41:05 +0000 [thread overview]
Message-ID: <11f4cba9-e12e-4804-ac04-259adee4cfae@gmail.com> (raw)
In-Reply-To: <1f737f82-9bc5-43b4-b78b-bf1b4393efc8@gmail.com>
Hi Rubén
On 29/03/2024 03:58, Rubén Justo wrote:
Thanks for re-rolling, this looks pretty good - I've left a couple of
small comments.
> @@ -1448,10 +1448,15 @@ 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 (rendered_hunk_index != hunk_index) {
> + render_hunk(s, hunk, 0, colored, &s->buf);
> + fputs(s->buf.buf, stdout);
> +
> + rendered_hunk_index = hunk_index;
This line could be grouped with the rest of this block without the blank
line if you wanted.
> + }
>
> strbuf_reset(&s->buf);
> +
I'm not sure what this new blank line is for - previously it was clear
that the call strbuf_reset() was grouped with the code that then reuses
the buffer. The rest of the changes look fine
Best Wishes
Phillip
> if (undecided_previous >= 0) {
> permitted |= ALLOW_GOTO_PREVIOUS_UNDECIDED_HUNK;
> strbuf_addstr(&s->buf, ",k");
> @@ -1646,13 +1651,15 @@ static int patch_update_file(struct add_p_state *s,
> hunk_index = i;
> } else if (s->answer.buf[0] == 's') {
> size_t splittable_into = hunk->splittable_into;
> - if (!(permitted & ALLOW_SPLIT))
> + if (!(permitted & ALLOW_SPLIT)) {
> err(s, _("Sorry, cannot split this hunk"));
> - else if (!split_hunk(s, file_diff,
> - hunk - file_diff->hunk))
> + } else if (!split_hunk(s, file_diff,
> + hunk - file_diff->hunk)) {
> color_fprintf_ln(stdout, s->s.header_color,
> _("Split into %d hunks."),
> (int)splittable_into);
> + rendered_hunk_index = -1;
> + }
> } else if (s->answer.buf[0] == 'e') {
> if (!(permitted & ALLOW_EDIT))
> err(s, _("Sorry, cannot edit this hunk"));
> @@ -1661,7 +1668,7 @@ static int patch_update_file(struct add_p_state *s,
> goto soft_increment;
> }
> } else if (s->answer.buf[0] == 'p') {
> - /* nothing special is needed */
> + rendered_hunk_index = -1;
> } else {
> const char *p = _(help_patch_remainder), *eol = p;
>
next prev parent reply other threads:[~2024-03-29 10:41 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 ` [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 [this message]
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=11f4cba9-e12e-4804-ac04-259adee4cfae@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=rjusto@gmail.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.
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).