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

[PATCH] am: simplify parsing of "--[no-]keep-cr"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 18, 2023, 18:22 UTC
Message-ID
<xmqqr0p5gjv3.fsf@gitster.g>

Command line options "--keep-cr" and its negation trigger OPT_SET_INT_F(PARSE_OPT_NONEG) to set a variable to 1 and 0 respectively. Using OPT_SET_INT() to implement the positive variant that sets the variable to 1 without specifying PARSE_OPT_NONEG gives us the negative variant to set it to 0 for free.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/am.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/builtin/am.c b/builtin/am.c
index dcb89439b1..39d3e11f84 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2347,12 +2347,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 			N_("pass -b flag to git-mailinfo"), KEEP_NON_PATCH),
 		OPT_BOOL('m', "message-id", &state.message_id,
 			N_("pass -m flag to git-mailinfo")),
-		OPT_SET_INT_F(0, "keep-cr", &keep_cr,
-			N_("pass --keep-cr flag to git-mailsplit for mbox format"),
-			1, PARSE_OPT_NONEG),
-		OPT_SET_INT_F(0, "no-keep-cr", &keep_cr,
-			N_("do not pass --keep-cr flag to git-mailsplit independent of am.keepcr"),
-			0, PARSE_OPT_NONEG),
+		OPT_SET_INT(0, "keep-cr", &keep_cr,
+			    N_("pass --keep-cr flag to git-mailsplit for mbox format"),
+			    1),
 		OPT_BOOL('c', "scissors", &state.scissors,
 			N_("strip everything before a scissors line")),
 		OPT_CALLBACK_F(0, "quoted-cr", &state.quoted_cr, N_("action"),
-- 
2.41.0-376-gcba07a324d
Message 1 of 1 in “am: simplify parsing of "--[no-]keep-cr"”
  1. am: simplify parsing of "--[no-]keep-cr"Junio C Hamano, Jul 18, 2023

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.