git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add-patch: response to unknown command
@ 2024-05-21  0:37 Rubén Justo
  2024-05-21  7:03 ` Patrick Steinhardt
  0 siblings, 1 reply; 21+ messages in thread
From: Rubén Justo @ 2024-05-21  0:37 UTC (permalink / raw)
  To: Git List

In 26998ed2a2 (add-patch: response to unknown command, 2024-04-29) we
introduced an error message that displays the invalid command entered by
the user.

We process a line received from the user, but we only accept
single-character commands.

To avoid confusion, include in the error message only the first
character received.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 add-patch.c                | 4 ++--
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/add-patch.c b/add-patch.c
index 2252895c28..d408a85353 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1692,8 +1692,8 @@ static int patch_update_file(struct add_p_state *s,
 						 "%.*s", (int)(eol - p), p);
 			}
 		} else {
-			err(s, _("Unknown command '%s' (use '?' for help)"),
-			    s->answer.buf);
+			err(s, _("Unknown command '%c' (use '?' for help)"),
+			    s->answer.buf[0]);
 		}
 	}
 
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 28a95a775d..6f5d3085af 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -60,7 +60,7 @@ test_expect_success 'warn about add.interactive.useBuiltin' '
 
 test_expect_success 'unknown command' '
 	test_when_finished "git reset --hard; rm -f command" &&
-	echo W >command &&
+	echo WW >command &&
 	git add -N command &&
 	git diff command >expect &&
 	cat >>expect <<-EOF &&
-- 
2.45.1.217.gdb529f37a6

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-05-23 15:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21  0:37 [PATCH] add-patch: response to unknown command Rubén Justo
2024-05-21  7:03 ` Patrick Steinhardt
2024-05-21 12:59   ` Rubén Justo
2024-05-21 15:52   ` Re* " Junio C Hamano
2024-05-21 22:27     ` Taylor Blau
2024-05-21 23:06       ` Junio C Hamano
2024-05-21 23:20     ` [PATCH v2] add-patch: enforce only one-letter response to prompts Junio C Hamano
2024-05-21 23:36       ` Eric Sunshine
2024-05-22  0:49         ` Junio C Hamano
2024-05-22  6:40       ` Dragan Simic
2024-05-22 16:23         ` Junio C Hamano
2024-05-22 19:03           ` Dragan Simic
2024-05-22 20:41             ` Junio C Hamano
2024-05-22 11:07       ` Patrick Steinhardt
2024-05-22 16:27         ` Junio C Hamano
2024-05-22 17:14       ` [PATCH v3] " Junio C Hamano
2024-05-22 17:38         ` Rubén Justo
2024-05-22 19:27           ` Junio C Hamano
2024-05-22 21:45         ` [PATCH v4] " Junio C Hamano
2024-05-23  5:31           ` Patrick Steinhardt
2024-05-23 15:58             ` Junio C Hamano

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 NNTP newsgroup(s).