git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] add-patch: response to unknown command

From
Rubén Justo <rjusto@gmail.com>
Date
May 21, 2024, 00:37 UTC
Message-ID
<1dbe4c61-d75f-45d9-95d2-ac8acae22c56@gmail.com>

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
Next: Patrick Steinhardt
Message 1 of 21 in “add-patch: response to unknown command”
  1. add-patch: response to unknown commandRubén Justo, May 21, 2024
  2. Patrick SteinhardtMay 21, 2024
  3. Rubén JustoMay 21, 2024
  4. Re* [PATCH] add-patch: response to unknown commandJunio C Hamano, May 21, 2024
  5. Taylor BlauMay 21, 2024
  6. Junio C HamanoMay 21, 2024
  7. add-patch: enforce only one-letter response to promptsJunio C Hamano, May 21, 2024
  8. Eric SunshineMay 21, 2024
  9. Junio C HamanoMay 22, 2024
  10. Dragan SimicMay 22, 2024
  11. Junio C HamanoMay 22, 2024
  12. Dragan SimicMay 22, 2024
  13. Junio C HamanoMay 22, 2024
  14. Patrick SteinhardtMay 22, 2024
  15. Junio C HamanoMay 22, 2024
  16. add-patch: enforce only one-letter response to promptsJunio C Hamano, May 22, 2024
  17. Rubén JustoMay 22, 2024
  18. Junio C HamanoMay 22, 2024
  19. add-patch: enforce only one-letter response to promptsJunio C Hamano, May 22, 2024
  20. Patrick SteinhardtMay 23, 2024
  21. Junio C HamanoMay 23, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.