mbox series

[v4,0/6] use the pager in 'add -p'

Message ID 1ef0ac3a-3be5-4fc2-93f8-46610f3d1880@gmail.com (mailing list archive)
Headers show
Series use the pager in 'add -p' | expand

Message

Rubén Justo June 3, 2024, 8:35 p.m. UTC
This iteration is a quick reroll to address the interactive.singleKey
option in the new '|' interactive command.

I've also used the improved wording for the help text, suggested by
Dragan.

The rest of the series remains the same.  Here is the range-diff from
v3:

Range-diff against v3:
-:  ---------- > 1:  49481da8a7 add-patch: test for 'p' command
-:  ---------- > 2:  865bb68508 pager: do not close fd 2 unnecessarily
-:  ---------- > 3:  9fcf244dac pager: introduce wait_for_pager
-:  ---------- > 4:  1e817a9ec0 pager: introduce setup_custom_pager
-:  ---------- > 5:  87dd368346 test-terminal: introduce --no-stdin-pty
1:  9fa538478d ! 6:  b691764a17 add-patch: introduce the command '|'
    @@ add-patch.c: N_("j - leave this hunk undecided, see next undecided hunk\n"
         "s - split the current hunk into smaller hunks\n"
         "e - manually edit the current hunk\n"
         "p - print the current hunk\n"
    -+   "| - pipe the current hunk to the pager, or |<program> to use a program'\n"
    ++   "| - use pager to show the current hunk, or use |<program> to customize\n"
         "? - print help\n");
      
      static int patch_update_file(struct add_p_state *s,
    @@ add-patch.c: static int patch_update_file(struct add_p_state *s,
      		} else if (s->answer.buf[0] == 'p') {
      			rendered_hunk_index = -1;
     +		} else if (ch == '|') {
    ++			strbuf_remove(&s->answer, 0, 1);
    ++			if (s->s.use_single_key && s->answer.len == 0) {
    ++				printf("%s", _("program? "));
    ++				fflush(stdout);
    ++				strbuf_getline(&s->answer, stdin);
    ++				strbuf_trim_trailing_newline(&s->answer);
    ++			}
    ++			strbuf_trim(&s->answer);
    ++			pager = s->answer.buf;
     +			rendered_hunk_index = -1;
    -+			pager = s->answer.buf + 1;
      		} else if (s->answer.buf[0] == '?') {
      			const char *p = _(help_patch_remainder), *eol = p;
      

base-commit: d3f616a4e56f359d84a9d439aa03dca1fe9ac280