Re: git commit -v does not removes the patch
- From
- Santi 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 >