From: Johannes Schindelin Date: Mon, 23 Jul 2007 10:40:33 GMT Subject: Re: [PATCH] Teach git-commit about commit message templates. Message-ID: In-Reply-To: <46A481B4.7000502@midwinter.com> Hi, On Mon, 23 Jul 2007, Steven Grimm wrote: > Johannes Schindelin wrote: > > Up until here, I was with you. But this feels very wrong. > > > > Why not compare COMMIT_MSG to the templatefile, if there is one? I.e. > > > > test ! -z "$templatefile" && cmp "$GIT_DIR"/COMMIT_MSG "$templatefile" && > > die "Unchanged message; will not commit" > > > > The template can itself have comments -- instructions or explanations of > fields to fill in, for example -- and since comments have been stripped > from COMMIT_MSG at this point, a comparison against such a template > would always fail. 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" } Ciao, Dscho