git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Grimm <koreth@midwinter.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Teach git-commit about commit message templates.
Date: Mon, 23 Jul 2007 18:56:09 +0800	[thread overview]
Message-ID: <46A48949.1020501@midwinter.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707231136530.14781@racer.site>

Johannes Schindelin wrote:
> Ah, I missed that.  But IIRC your patch does not wrap that logic behind 
> test ! -z "$templatefile", right?  So this is my modified suggestion:
>
> test ! -z "$templatefile" && {
> 	grep -vie '^Signed-off-by:' < "$GIT_DIR"/COMMIT_MSG" > "$GIT_DIR"/tmp1
> 	grep -ve '^#' < "$templatefile" > "$GIT_DIR"/tmp1
> 	trap 'rm "$GIT_DIR"/tmp[12]' 0
> 	cmp "$GIT_DIR"/tmp[12] &&
> 	die "Unchanged message; will not commit"
> }
>   

So you are suggesting I do this in addition to the existing git-commit 
stripping of Signed-off-by: lines? I can certainly do that, but I didn't 
want to make two passes over the commit message doing exactly the same 
stripping.

Hmm, maybe I should outline my understanding of the current (unpatched) 
behavior and what I want it to do. Currently:

* Strip off all comment lines (happens when COMMIT_MSG is created)
* Strip off all Signed-off-by: lines
* Trim whitespace
* If the result has no content (`wc -l` == 0), abort.

With the patch, my intent was:

* Strip off all comment lines
* Strip off all Signed-off-by: lines
* Trim whitespace
* If the result has no content (! -s file), abort.
* If a template file was specified:
   * Strip off all comment and Signed-off-by: lines from the template
   * Trim whitespace from the template
   * If the resulting trimmed template is the same as the trimmed commit 
message, abort.

So I guess before getting to the specifics of the code, I'll ask: does 
the above make sense as a design? I wanted to preserve the existing 
behavior in the absence of a template.

Since the existing code is already stripping Signed-off-by: lines to 
test for a zero-length commit message, I figured I should reuse that 
work. However, it's no big deal to do it twice if people feel that 
results in more readable code -- certainly no human will ever notice the 
time it takes to re-grep the commit message.

-Steve

  reply	other threads:[~2007-07-23 10:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-23  4:17 [PATCH] Teach git-commit about commit message templates Steven Grimm
2007-07-23 10:04 ` Johannes Schindelin
2007-07-23 10:23   ` Steven Grimm
2007-07-23 10:40     ` Johannes Schindelin
2007-07-23 10:56       ` Steven Grimm [this message]
2007-07-23 11:58         ` Johannes Schindelin
2007-07-23 17:12         ` Junio C Hamano
2007-07-24 12:01           ` Steven Grimm
2007-07-24 21:43             ` Junio C Hamano
2007-07-25  6:42               ` Steven Grimm
2007-07-25  7:39                 ` Junio C Hamano

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=46A48949.1020501@midwinter.com \
    --to=koreth@midwinter.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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).