git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cg-commit: fix signed off handling
@ 2006-08-25  0:27 Jonas Fonseca
  2006-09-24 17:45 ` Petr Baudis
  0 siblings, 1 reply; 4+ messages in thread
From: Jonas Fonseca @ 2006-08-25  0:27 UTC (permalink / raw)
  To: git

Handle the sign off insertion before starting the CG: comment lines. Also,
fix typo in grepping for existing sign off lines.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---

The late calling of the add_signoff function has multiple problems,
since at that point comment lines has already been added and the sign
off line will end up in only one of the log message files.

 cg-commit |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/cg-commit b/cg-commit
index 5cebd81..b0b5c34 100755
--- a/cg-commit
+++ b/cg-commit
@@ -406,12 +406,10 @@ # Always have at least one blank line, t
 # the poor people whose text editor has no 'O' command.
 [ "$written" ] || { tty -s && echo >>"$LOGMSG"; }
 
-add_signoff() {
-	if [ "$signoff" ] && ! grep -q -i "signed-off-by: $signoff" $LOGMSG; then
-		grep -q -i sign-off-by $LOGMSG || echo
-		echo "Signed-off-by: $signoff"
-	fi >> $LOGMSG
-}
+if [ "$signoff" ] && ! grep -q -i "signed-off-by: $signoff" $LOGMSG; then
+	grep -q -i signed-off-by $LOGMSG || echo
+	echo "Signed-off-by: $signoff"
+fi >> $LOGMSG
 
 # CG: -----------------------------------------------------------------------
 editor_comment_start commit
@@ -472,7 +470,6 @@ editor_msg_end
 
 cp "$LOGMSG" "$LOGMSG2"
 if tty -s; then
-	add_signoff
 	if [ "$editor" ] && ! editor $commitalways commit c; then
 		rm "$LOGMSG" "$LOGMSG2"
 		[ "$review" ] && rm "$PATCH"
@@ -503,7 +500,6 @@ __END__
 	editor_parse_setif GIT_AUTHOR_DATE Date
 else
 	cat >>"$LOGMSG2"
-	add_signoff
 fi
 
 if [ ! "$review" ]; then
-- 
Jonas Fonseca

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cg-commit: fix signed off handling
  2006-08-25  0:27 [PATCH] cg-commit: fix signed off handling Jonas Fonseca
@ 2006-09-24 17:45 ` Petr Baudis
  2006-09-24 18:32   ` Jonas Fonseca
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Baudis @ 2006-09-24 17:45 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git

Dear diary, on Fri, Aug 25, 2006 at 02:27:40AM CEST, I got a letter
where Jonas Fonseca <fonseca@diku.dk> said that...
> Handle the sign off insertion before starting the CG: comment lines. Also,
> fix typo in grepping for existing sign off lines.
> 
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
> ---
> 
> The late calling of the add_signoff function has multiple problems,
> since at that point comment lines has already been added and the sign
> off line will end up in only one of the log message files.

Well, the commit that moved this was

Commit: 4cf220db10c0b937f9852513effc5565fcbb4f86
Author: Petr Baudis <pasky@pixie.suse.cz> Thu, 20 Jul 2006 11:37:31 -0400

    * cg-commit:

    Add signoff past the message if getting it from stdin

What about this?

diff --git a/cg-commit b/cg-commit
index 43e6c6c..beedb6f 100755
--- a/cg-commit
+++ b/cg-commit
@@ -402,10 +402,6 @@ if [ "$msgfile" ]; then
 	written=1
 fi
 
-# Always have at least one blank line, to ease the editing for
-# the poor people whose text editor has no 'O' command.
-[ "$written" ] || { tty -s && echo >>"$LOGMSG"; }
-
 add_signoff() {
 	if [ "$signoff" ] && ! grep -q -i "signed-off-by: $signoff" $LOGMSG; then
 		grep -q -i sign-off-by $LOGMSG || echo
@@ -413,6 +409,16 @@ add_signoff() {
 	fi >> $LOGMSG
 }
 
+if tty -s; then
+	# Always have at least one blank line, to ease the editing for
+	# the poor people whose text editor has no 'O' command.
+	[ "$written" ] || echo >>"$LOGMSG"
+	# Also, add the signoff line _now_ before spewing out CG: lines.
+	# (In case of non-tty input we do it later after taking the actual
+	# log message from stdin.)
+	add_signoff
+fi
+
 # CG: -----------------------------------------------------------------------
 editor_comment_start commit
 
@@ -472,7 +478,6 @@ editor_msg_end
 
 cp "$LOGMSG" "$LOGMSG2"
 if tty -s; then
-	add_signoff
 	if [ "$editor" ] && ! editor $commitalways commit c; then
 		rm "$LOGMSG" "$LOGMSG2"
 		[ "$review" ] && rm "$PATCH"

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cg-commit: fix signed off handling
  2006-09-24 17:45 ` Petr Baudis
@ 2006-09-24 18:32   ` Jonas Fonseca
  2006-09-24 20:05     ` Petr Baudis
  0 siblings, 1 reply; 4+ messages in thread
From: Jonas Fonseca @ 2006-09-24 18:32 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

Petr Baudis <pasky@suse.cz> wrote Sun, Sep 24, 2006:
> Dear diary, on Fri, Aug 25, 2006 at 02:27:40AM CEST, I got a letter
> where Jonas Fonseca <fonseca@diku.dk> said that...
> > Handle the sign off insertion before starting the CG: comment lines. Also,
> > fix typo in grepping for existing sign off lines.
> > 
> > Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
> > ---
> > 
> > The late calling of the add_signoff function has multiple problems,
> > since at that point comment lines has already been added and the sign
> > off line will end up in only one of the log message files.
> 
> Well, the commit that moved this was
> 
> Commit: 4cf220db10c0b937f9852513effc5565fcbb4f86
> Author: Petr Baudis <pasky@pixie.suse.cz> Thu, 20 Jul 2006 11:37:31 -0400
> 
>     * cg-commit:
> 
>     Add signoff past the message if getting it from stdin
> 
> What about this?

The thing you committed seems to work, so I am happy again. :) 

> diff --git a/cg-commit b/cg-commit
> index 43e6c6c..beedb6f 100755
> --- a/cg-commit
> +++ b/cg-commit
> @@ -402,10 +402,6 @@ if [ "$msgfile" ]; then
>  	written=1
>  fi
>  
> -# Always have at least one blank line, to ease the editing for
> -# the poor people whose text editor has no 'O' command.
> -[ "$written" ] || { tty -s && echo >>"$LOGMSG"; }
> -
>  add_signoff() {
>  	if [ "$signoff" ] && ! grep -q -i "signed-off-by: $signoff" $LOGMSG; then
>  		grep -q -i sign-off-by $LOGMSG || echo
			   ^^^^^^^^^^^

My patch also fixed this to grep for "signed-off-by".

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cg-commit: fix signed off handling
  2006-09-24 18:32   ` Jonas Fonseca
@ 2006-09-24 20:05     ` Petr Baudis
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Baudis @ 2006-09-24 20:05 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git

Dear diary, on Sun, Sep 24, 2006 at 08:32:46PM CEST, I got a letter
where Jonas Fonseca <fonseca@diku.dk> said that...
> Petr Baudis <pasky@suse.cz> wrote Sun, Sep 24, 2006:
> > diff --git a/cg-commit b/cg-commit
> > index 43e6c6c..beedb6f 100755
> > --- a/cg-commit
> > +++ b/cg-commit
> > @@ -402,10 +402,6 @@ if [ "$msgfile" ]; then
> >  	written=1
> >  fi
> >  
> > -# Always have at least one blank line, to ease the editing for
> > -# the poor people whose text editor has no 'O' command.
> > -[ "$written" ] || { tty -s && echo >>"$LOGMSG"; }
> > -
> >  add_signoff() {
> >  	if [ "$signoff" ] && ! grep -q -i "signed-off-by: $signoff" $LOGMSG; then
> >  		grep -q -i sign-off-by $LOGMSG || echo
> 			   ^^^^^^^^^^^
> 
> My patch also fixed this to grep for "signed-off-by".

Oh, thanks - fixed.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-09-24 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-25  0:27 [PATCH] cg-commit: fix signed off handling Jonas Fonseca
2006-09-24 17:45 ` Petr Baudis
2006-09-24 18:32   ` Jonas Fonseca
2006-09-24 20:05     ` Petr Baudis

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).