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

Re: [PATCH 5/5] commit, status: use status_printf{,_ln,_more} helpers

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 27, 2011, 09:50 UTC
Message-ID
<20110227095022.GB24391@elie>
In-Reply-To
<7vaahh6dw0.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
Show 16 quoted lines
>> +++ b/builtin/commit.c
>> @@ -694,50 +694,51 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>>  	if (use_editor && include_status) {
>>  		char *ai_tmp, *ci_tmp;
>>  		if (in_merge)
>> -...
>> +			status_printf_ln(s, GIT_COLOR_NORMAL,
>> +				"\n"
>> +				"It looks like you may be committing a MERGE.\n"
>> +				"If this is not correct, please remove the file\n"
>> +				"	%s\n"
>> +				"and try again.\n"
>> +				"",
>
> This trick to avoid difference-in-comma-when-updated was semi "Huh" when
> reading.  Is it worth it?
The hint starts and ends with a blank (commented) line.
			status_printf(s, GIT_COLOR_NORMAL,
				"\n"
				...
				"and try again.\n"
				"\n",
would be clearer.
Show 9 quoted lines
> The "attribute((format))" safety seems to bite us here...
>
>     $ Meta/Make --pedantic builtin/commit.o
>         CC builtin/commit.o
>     cc1: warnings being treated as errors
>     builtin/commit.c: In function 'prepare_to_commit':
>     builtin/commit.c:741: error: zero-length printf format string
>
> In wt-status.c many similar ones exist, unfortunately.

What a warning. :) I don't understand how it is supposed to benefit the world[1].

	status_printf_ln(s, GIT_COLOR_NORMAL, "%s", "");
	status_printf(s, GIT_COLOR_NORMAL, "\n");
I suppose the latter could be a bearable workaround.
[1] http://gcc.gnu.org/ml/gcc-patches/2002-05/msg01462.html
Previous: Junio C Hamano
Message 8 of 8 in “status, commit: separate "# " from the translatable part of output”
  1. 0/5 status, commit: separate "# " from the translatable part of outputJonathan Nieder, Feb 26, 2011
  2. 1/5 compat: provide a fallback va_copy definitionJonathan Nieder, Feb 26, 2011
  3. 2/5 strbuf: add strbuf_vaddfJonathan Nieder, Feb 26, 2011
  4. 3/5 wt-status: add helpers for printing wt-status linesJonathan Nieder, Feb 26, 2011
  5. 4/5 commit: refer to commit template as s->fpJonathan Nieder, Feb 26, 2011
  6. 5/5 commit, status: use status_printf{,_ln,_more} helpersJonathan Nieder, Feb 26, 2011
  7. Junio C HamanoFeb 27, 2011
  8. Jonathan NiederFeb 27, 2011

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.