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

Re: [PATCH v2] builtin-commit: Include the diff in the commit message when verbose.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 22, 2007, 19:14 UTC
Message-ID
<7vzlx63xey.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<Pine.LNX.4.64.0711221049350.27959@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 11 quoted lines
> On Wed, 21 Nov 2007, Kristian Høgsberg wrote:
>
>> +
>> +	/* Truncate the message just before the diff, if any. */
>> +	p = strstr(sb.buf, "\ndiff --git a/");
>> +	if (p != NULL)
>> +		strbuf_setlen(&sb, p - sb.buf);
>> +
>
> Is this related to the change in wt_status?  If so, wouldn't we want to 
> suppress the diff, instead of generating it, and then killing it later?
This corresponds to the sed script near l.545 in git-commit.sh.

I've been wondering if it would be better not to have this logic but instead "git commit -v" to show the diff text prefixed with '# ' to make it a proper comment, by the way.

> Besides, you'd want to leave the \n there: strbuf_setlen(&sb, p + 1 - 
> sb.buf);
Yup.
Show 5 quoted lines
>> +	/* Sigh, the entire diff machinery is hardcoded to output to
>> +	 * stdout.  Do the dup-dance...*/
>
> I wonder how much effort it would be to change that.  Not that it would 
> help too much, since we want the output in a strbuf anyway.

The codepath is preparing COMMIT_EDITMSG file for the user to edit (or to the standard output, if this is "git status -v").

I do not know about "strbuf" part; resulting patch text could be large and in most cases the callers would rather flush it to outside (either pipe or file) as soon as possible than having to keep it all in core.

I was trying to do the stdout -> FILE *fp conversion of diff.c last night but dropped it halfway, after finding one puts() misconversion and fixing it. The changes should mostly be straightforward but the result felt ugly.

Previous: Jeff KingNext: Kristian Høgsberg
Message 4 of 5 in “builtin-commit: Include the diff in the commit message when verbose.”
  1. builtin-commit: Include the diff in the commit message when verbose.Kristian Høgsberg, Nov 22, 2007
  2. Johannes SchindelinNov 22, 2007
  3. Jeff KingNov 22, 2007
  4. Junio C HamanoNov 22, 2007
  5. Kristian HøgsbergNov 26, 2007

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.