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

Re: git commit -v does not removes the patch

From
SBSanti Béjar <santi@agolina.net>
Date
Nov 11, 2008, 11:20 UTC
Message-ID
<adf1fd3d0811110320w53f9745bs68a6bd1b2e437f42@mail.gmail.com>
In-Reply-To
<20081111102914.GA30330@coredump.intra.peff.net>
On Tue, Nov 11, 2008 at 11:29 AM, Jeff King <peff@peff.net> wrote:
Show 19 quoted lines
> On Tue, Nov 11, 2008 at 08:56:34AM +0100, Santi Béjar wrote:
>
>> Almost! I have diff.mnemonicprefix=true, if I unset it everything works.
>
> Ah, indeed. The obvious fix is just loosening our match a little bit:
>
> diff --git a/builtin-commit.c b/builtin-commit.c
> index 93ca496..a721990 100644
> --- a/builtin-commit.c
> +++ b/builtin-commit.c
> @@ -1015,7 +1015,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>        }
>
>        /* Truncate the message just before the diff, if any. */
> -       p = strstr(sb.buf, "\ndiff --git a/");
> +       p = strstr(sb.buf, "\ndiff --git ");
>        if (p != NULL)
>                strbuf_setlen(&sb, p - sb.buf + 1);
>
It fixes it, thanks.
Show 8 quoted lines
>
> But I have to wonder if there is some more robust solution. It seems
> like this can have false positives if you include diff output in your
> commit message, and a potential false negative if you delete the newline
> (e.g., delete everything up to "diff --git", making it the first line).
>
> But I guess we haven't seen a lot of complaints, so maybe those
> conditions aren't worth worrying about.

The false positive/negative were already possible, it was just a little more narrow. So not worth worrying about. Also, if you really want a diff in the commit message you can use the --cleanup option.

A more robust solution could be to have a:
# Everything after this line will be removed from the commit message
But, again, not worth.
Santi
>
> -Peff
>
Previous: Jeff KingNext: Junio C Hamano
Message 8 of 22 in “git commit -v does not removes the patch”
  1. Santi BéjarNov 10, 2008
  2. Jeff KingNov 10, 2008
  3. Santi BéjarNov 10, 2008
  4. Junio C HamanoNov 10, 2008
  5. Jeff KingNov 11, 2008
  6. Santi BéjarNov 11, 2008
  7. Jeff KingNov 11, 2008
  8. Santi BéjarNov 11, 2008
  9. Junio C HamanoNov 11, 2008
  10. Jeff KingNov 12, 2008
  11. 1/5 define empty tree sha1 as a macroJeff King, Nov 12, 2008
  12. 2/5 wt-status: refactor initial commit printingJeff King, Nov 12, 2008
  13. 3/5 status: show "-v" diff even for initial commitJeff King, Nov 12, 2008
  14. 4/5 commit: loosen pattern for matching "-v" diffJeff King, Nov 12, 2008
  15. 5/5 commit: only strip diff from message in verbose modeJeff King, Nov 12, 2008
  16. Jeff KingNov 12, 2008
  17. Junio C HamanoNov 13, 2008
  18. SZEDER GáborNov 20, 2008
  19. Jeff KingNov 20, 2008
  20. SZEDER GáborNov 22, 2008
  21. Jeff KingNov 22, 2008
  22. Junio C HamanoNov 22, 2008

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.