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

Re: [PATCH 2/2] format-patch: Add --cover-letter-wrap

From
Stephen Boyd <bebarino@gmail.com>
Date
Jul 2, 2009, 06:45 UTC
Message-ID
<4A4C5774.9050905@gmail.com>
In-Reply-To
<5035332845f173ac9c236a90621ca04ea6633b10.1246404999.git.joe@perches.com>
Joe Perches wrote:
Show 22 quoted lines
> @@ -792,6 +806,27 @@ static int output_directory_callback(const struct option *opt, const char *arg,
>  	return 0;
>  }
>  
> +static int cls_callback(const struct option *opt, const char *arg, int unset)
> +{
> +	if (unset)
> +		cls.cover_letter_wrap = 0;
> +	else {
> +		int i1, i2, i3;
> +		if (!arg)
> +			return 1;
> +		int arg_count = sscanf(arg, "%d,%d,%d", &i1, &i2, &i3);
> +		if (arg_count <= 0)
> +			return 1;
> +		if (arg_count >= 1)
> +			cls.cover_letter_wrappos = i1;
> +		if (arg_count >= 2)
> +			cls.cover_letter_indent1 = i2;
> +		if (arg_count >= 3)
> +			cls.cover_letter_indent2 = i3;
> +		}
This bracket is one indent off.

I'm not sure, but can this be simplified to just setting the struct members directly through sscanf? You won't need to have these if's in that case. I think something like --cover-letter-wrap="" would be equivalent to just using the defaults and not an error. Does that sound right?

Show 13 quoted lines
> +	return 0;
> +}
> +
>  static int thread_callback(const struct option *opt, const char *arg, int unset)
>  {
>  	int *thread = (int *)opt->value;
> @@ -875,6 +910,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  			    "print patches to standard out"),
>  		OPT_BOOLEAN(0, "cover-letter", &cover_letter,
>  			    "generate a cover letter"),
> +		{ OPTION_CALLBACK, 0, "cover-letter-wrap", &cls, NULL,
> +			    "control the cover letter format",
> +			    PARSE_OPT_OPTARG, cls_callback },

Why is this PARSE_OPT_OPTARG? I only see the choice of having arguments or prefixed with a --no. Also, please use PARSE_OPT_LITERAL_ARGHELP and give it the help string you use in the docs (<width>[,<indent1>[,<indent2>]]).

Previous: Joe Perches
Message 8 of 8 in “format-patch and send-email”
  1. 0/2 format-patch and send-emailJoe Perches, Jun 30, 2009
  2. 1/2 git-send-email.perl: Don't add header "In-Reply-To:" when --no-chain-reply-to setJoe Perches, Jun 30, 2009
  3. Markus HeidelbergJul 1, 2009
  4. Joe PerchesJul 1, 2009
  5. Markus HeidelbergJul 1, 2009
  6. Joe PerchesJul 1, 2009
  7. 2/2 format-patch: Add --cover-letter-wrapJoe Perches, Jun 30, 2009
  8. Stephen BoydJul 2, 2009

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.