Re: [PATCH v3 0/6] use the pager in 'add -p'
On Sun, Jun 02, 2024 at 10:11:49AM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> By the way, although I personally do not have much sympathy to those
> who set it, in the presence of interactive.singleKey configuration
> variable, a command that takes optional argument may turn out to be
> a mistake, as the user cannot give the argument even if they wanted
> to, when the configuration variable is set to true.
Well spotted.
Perhaps we can do something like:
diff --git a/add-patch.c b/add-patch.c
index 5a586d1b9b..01525214f9 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1685,8 +1685,17 @@ 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) {
+ printf("%s", _("program? "));
+ fflush(stdout);
+ strbuf_getline(&s->answer, stdin);
+ strbuf_trim_trailing_newline(&s->answer);
+ }
rendered_hunk_index = -1;
- pager = s->answer.buf + 1;
+ pager = s->answer.buf;
} else if (s->answer.buf[0] == '?') {
const char *p = _(help_patch_remainder), *eol = p;
I agree this needs to be addressed in this series.
I'd prefer to leave the feature of reusing the command, to another
series.