git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kristian Høgsberg" <krh@redhat.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: [PATCH v2] builtin-commit: Include the diff in the commit message when verbose.
Date: Mon, 26 Nov 2007 10:21:15 -0500	[thread overview]
Message-ID: <1196090475.2875.10.camel@hinata.boston.redhat.com> (raw)
In-Reply-To: <7vzlx63xey.fsf@gitster.siamese.dyndns.org>


On Thu, 2007-11-22 at 11:14 -0800, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 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.

Yeah, that would be nicer... I think the best way to do this is to do a
formatting callback for the diff machinery as Jeff suggests, which can
then prefix '# ' and write it to a FILE *.

> > Besides, you'd want to leave the \n there: strbuf_setlen(&sb, p + 1 - 
> > sb.buf);
> 
> Yup.

Right, off-by-one.  Effectively it doesn't make a difference, since
there will always be a comment line above the diff,  When stripspace
removes the comments it fixes up the end-of-line problem.  Patch below.

cheers,
Kristian


>From 58eac54a00d3eb6a311c6fb4faa67eb831c60e01 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Kristian=20H=C3=B8gsberg?= <krh@redhat.com>
Date: Mon, 26 Nov 2007 10:16:08 -0500
Subject: [PATCH] Fix off-by-one error when truncating the diff out of the commit message.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
---
 builtin-commit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 45e51b1..330f778 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -762,7 +762,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/");
 	if (p != NULL)
-		strbuf_setlen(&sb, p - sb.buf);
+		strbuf_setlen(&sb, p - sb.buf + 1);
 
 	stripspace(&sb, 1);
 	if (sb.len < header_len || message_is_empty(&sb, header_len)) {
-- 
1.5.3.4.206.g58ba4

      reply	other threads:[~2007-11-26 15:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-22  2:54 [PATCH v2] builtin-commit: Include the diff in the commit message when verbose Kristian Høgsberg
2007-11-22 10:52 ` Johannes Schindelin
2007-11-22 11:13   ` Jeff King
2007-11-22 19:14   ` Junio C Hamano
2007-11-26 15:21     ` Kristian Høgsberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1196090475.2875.10.camel@hinata.boston.redhat.com \
    --to=krh@redhat.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).