threads / patch / 530

patchMake use of external editor work like CVS

Subject: [PATCH Cogito] Make use of external editor work like CVS

## tl;dr

20 messages between May 8, 2005 and May 9, 2005. Diffs are folded; open one to read it.

replies: 19people: 4as markdown or json

Marcel Holtmann· May 8, 2005, 15:02 UTC · lore
Hi Petr,

this is a modified version of my patch that integrates the your latest modifications to cg-commit and also fixes the cleanup of the temporary files when we abort the operation.

Regards
Marcel
[PATCH] Make use of external editor work like CVS

The lines starting with `CG:' should be a trailer and not at the top of the message presented in the editor. Also extend the number of `-' up to 74 characters so that people know when they should start a new line. If it's not a merge and no commit text is given as parameter then add an extra empty line at the top. And don't forget to take care of the temporary files when a commit is unneeded or canceled.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

--- commit 895bcd02ecc96bed1d35275def6dca1ca6f20e5f tree be440e169fa3b5ec5450fa9574cd8789b0e3ab20 parent 64142a39e7a6701e69654a930de86a9fe296f8a0 author Marcel Holtmann <marcel@holtmann.org> Sun, 08 May 2005 16:58:50 +0200 committer Marcel Holtmann <marcel@holtmann.org> Sun, 08 May 2005 16:58:50 +0200

 cg-commit |   63 ++++++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 37 insertions(+), 26 deletions(-)
Show changes to diff +37 −26
Index: cg-commit
===================================================================
--- 8bb38f8bfdc7411460c300c811da1987173f412f/cg-commit  (mode:100755)
+++ be440e169fa3b5ec5450fa9574cd8789b0e3ab20/cg-commit  (mode:100755)
@@ -61,26 +61,10 @@
 
 LOGMSG=$(mktemp -t gitci.XXXXXX)
 LOGMSG2=$(mktemp -t gitci2.XXXXXX)
-echo CG: ---------------------------------------------------------- >>$LOGMSG
-echo CG: Lines beggining with CG: will be automatically removed     >>$LOGMSG
-echo CG:                                                            >>$LOGMSG
-if [ ! "$ignorecache" ]; then
-	if [ ! "${commitfiles[*]}" ]; then
-		echo 'Nothing to commit.' >&2
-		exit 2
-	fi
-	for file in "${commitfiles[@]}"; do
-		# Prepend a letter describing whether it's addition,
-		# removal or update. Or call git status on those files.
-		echo CG: $file >>$LOGMSG
-		[ "$msgs" ] && echo $file
-	done
-	echo CG: >>$LOGMSG
-fi
 
 if [ "$merging" ]; then
-	echo -n 'Merge with ' >>$LOGMSG
-	[ "$msgs" ] && echo -n 'Merge with '
+	echo -n "Merge with " >>$LOGMSG
+	[ "$msgs" ] && echo -n "Merge with "
 	[ -s .git/merging-sym ] || cp .git/merging .git/merging-sym
 	for sym in $(cat .git/merging-sym); do
 		uri=$(cat .git/branches/$sym)
@@ -88,28 +72,55 @@
 		echo "$uri" >>$LOGMSG
 		[ "$msgs" ] && echo "$uri"
 	done
-	echo >>$LOGMSG
+else
+	first=1
 fi
-first=1
+
 for msg in "${msgs[@]}"; do
 	if [ "$first" ]; then
 		first=
 	else
 		echo >>$LOGMSG
 	fi
-	echo $msg | fmt >>$LOGMSG
+	echo $msg | fmt -s -w 74 >>$LOGMSG
 done
+
+if [ "$first" ]; then
+	echo >>$LOGMSG
+fi
+
+echo "CG: ----------------------------------------------------------------------" >>$LOGMSG
+echo "CG: Enter Log.  Lines beginning with \`CG:' are removed automatically"      >>$LOGMSG
+if [ ! "$ignorecache" ]; then
+	if [ ! "${commitfiles[*]}" ]; then
+		rm $LOGMSG $LOGMSG2
+		die 'Nothing to commit.'
+	fi
+	echo "CG: " >>$LOGMSG
+	echo "CG: Modified Files:" >>$LOGMSG
+	for file in "${commitfiles[@]}"; do
+		# Prepend a letter describing whether it's addition,
+		# removal or update. Or call git status on those files.
+		echo "CG:    $file" >>$LOGMSG
+		[ "$msgs" ] && echo "$file"
+	done
+fi
+echo "CG: ----------------------------------------------------------------------" >>$LOGMSG
+
 cp $LOGMSG $LOGMSG2
 if tty -s; then
 	if ! [ "$msgs" ]; then
-		${EDITOR:-vi} $LOGMSG2
-		[ $LOGMSG2 -nt $LOGMSG ] || die 'Commit message not modified, commit aborted'
+		${EDITOR:-vi} $LOGMSG
+		if [ ! $LOGMSG -nt $LOGMSG2 ]; then
+			rm $LOGMSG $LOGMSG2
+			die 'Commit message not modified, commit aborted.'
+		fi
 	fi
 else
-	cat >>$LOGMSG2
+	cat >>$LOGMSG
 fi
-grep -v ^CG: $LOGMSG2 >$LOGMSG
-rm $LOGMSG2
+grep -v ^CG: $LOGMSG >$LOGMSG2
+mv $LOGMSG2 $LOGMSG
 
 if [ ! "$ignorecache" ]; then
 	if [ "$customfiles" ]; then
Sean· May 8, 2005, 15:24 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

On Sun, May 8, 2005 11:02 am, Marcel Holtmann said:
Show 6 quoted lines
> Hi Petr,
>
> this is a modified version of my patch that integrates the your latest
> modifications to cg-commit and also fixes the cleanup of the temporary
> files when we abort the operation.
>
Hi Marcel,

What do you think about providing a per-repository commit template? So, if say ".git/commit.form" exists, use it instead of the default?

At a minimum, it would be nice to include a reminder about adding a "Signed-off-by:" line.

Sean
Petr Baudis· May 8, 2005, 15:25 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 05:02:30PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

> Hi Petr,
Hi,
> this is a modified version of my patch that integrates the your latest
> modifications to cg-commit and also fixes the cleanup of the temporary
> files when we abort the operation.
...and I've just pushed more modifications. I'm so evil.
Show 10 quoted lines
> [PATCH] Make use of external editor work like CVS
> 
> The lines starting with `CG:' should be a trailer and not at the top
> of the message presented in the editor. Also extend the number of `-'
> up to 74 characters so that people know when they should start a new
> line. If it's not a merge and no commit text is given as parameter
> then add an extra empty line at the top. And don't forget to take
> care of the temporary files when a commit is unneeded or canceled.
> 
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

What is so special about 74 columns? Why not 75 (fmt default), or 72 (emails)?

Also, I'd prefer the empty line to be always there in front of the CG: stuff (two empty lines in case of merge - I want to encourage people to keep possible details w.r.t. the merge separated by an empty line from the merge information), and when reading it back cg-commit should strip any trailing empty lines.

Show 9 quoted lines
> Index: cg-commit
> ===================================================================
> --- 8bb38f8bfdc7411460c300c811da1987173f412f/cg-commit  (mode:100755)
> +++ be440e169fa3b5ec5450fa9574cd8789b0e3ab20/cg-commit  (mode:100755)
>  if [ "$merging" ]; then
> -	echo -n 'Merge with ' >>$LOGMSG
> -	[ "$msgs" ] && echo -n 'Merge with '
> +	echo -n "Merge with " >>$LOGMSG
> +	[ "$msgs" ] && echo -n "Merge with "

We aren't too consistent about this anyway now, so you might as well let it not clutter your patch. ;-)

Show 19 quoted lines
>  cp $LOGMSG $LOGMSG2
>  if tty -s; then
>  	if ! [ "$msgs" ]; then
> -		${EDITOR:-vi} $LOGMSG2
> -		[ $LOGMSG2 -nt $LOGMSG ] || die 'Commit message not modified, commit aborted'
> +		${EDITOR:-vi} $LOGMSG
> +		if [ ! $LOGMSG -nt $LOGMSG2 ]; then
> +			rm $LOGMSG $LOGMSG2
> +			die 'Commit message not modified, commit aborted.'
> +		fi
>  	fi
>  else
> -	cat >>$LOGMSG2
> +	cat >>$LOGMSG
>  fi
> -grep -v ^CG: $LOGMSG2 >$LOGMSG
> -rm $LOGMSG2
> +grep -v ^CG: $LOGMSG >$LOGMSG2
> +mv $LOGMSG2 $LOGMSG
Why are you messing with the $LOGMSG variables here?
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 15:43 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 5 quoted lines
> > this is a modified version of my patch that integrates the your latest
> > modifications to cg-commit and also fixes the cleanup of the temporary
> > files when we abort the operation.
> 
> ...and I've just pushed more modifications. I'm so evil.
attached is another version of the patch.
Show 13 quoted lines
> > [PATCH] Make use of external editor work like CVS
> > 
> > The lines starting with `CG:' should be a trailer and not at the top
> > of the message presented in the editor. Also extend the number of `-'
> > up to 74 characters so that people know when they should start a new
> > line. If it's not a merge and no commit text is given as parameter
> > then add an extra empty line at the top. And don't forget to take
> > care of the temporary files when a commit is unneeded or canceled.
> > 
> > Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> 
> What is so special about 74 columns? Why not 75 (fmt default), or 72
> (emails)?

I ended up with 74, because "CG" has only two letters instead of "CVS" which has three. And cg-log uses a prefix of four whitespaces. This leaves two free characters at the end of a line if your terminal uses a width of 80 characters. The decision was of cosmetic nature.

Show 5 quoted lines
> Also, I'd prefer the empty line to be always there in front of the CG:
> stuff (two empty lines in case of merge - I want to encourage people to
> keep possible details w.r.t. the merge separated by an empty line from
> the merge information), and when reading it back cg-commit should strip
> any trailing empty lines.

I think we should differentiate between the merges. There is no need for additional information if it is an automatic merge (no conflicts) and in general it makes no sense to open the editor (until forced). I wanted to address this later. And yes in case of a manual merge it is a good idea to add two extra empty lines at the top.

Another good idea is maybe to remove empty lines at the top and bottom before doing the commit.

Show 12 quoted lines
> > Index: cg-commit
> > ===================================================================
> > --- 8bb38f8bfdc7411460c300c811da1987173f412f/cg-commit  (mode:100755)
> > +++ be440e169fa3b5ec5450fa9574cd8789b0e3ab20/cg-commit  (mode:100755)
> >  if [ "$merging" ]; then
> > -	echo -n 'Merge with ' >>$LOGMSG
> > -	[ "$msgs" ] && echo -n 'Merge with '
> > +	echo -n "Merge with " >>$LOGMSG
> > +	[ "$msgs" ] && echo -n "Merge with "
> 
> We aren't too consistent about this anyway now, so you might as well
> let it not clutter your patch. ;-)
I was moving parts of the code so I addressed it ;)
Show 21 quoted lines
> >  cp $LOGMSG $LOGMSG2
> >  if tty -s; then
> >  	if ! [ "$msgs" ]; then
> > -		${EDITOR:-vi} $LOGMSG2
> > -		[ $LOGMSG2 -nt $LOGMSG ] || die 'Commit message not modified, commit aborted'
> > +		${EDITOR:-vi} $LOGMSG
> > +		if [ ! $LOGMSG -nt $LOGMSG2 ]; then
> > +			rm $LOGMSG $LOGMSG2
> > +			die 'Commit message not modified, commit aborted.'
> > +		fi
> >  	fi
> >  else
> > -	cat >>$LOGMSG2
> > +	cat >>$LOGMSG
> >  fi
> > -grep -v ^CG: $LOGMSG2 >$LOGMSG
> > -rm $LOGMSG2
> > +grep -v ^CG: $LOGMSG >$LOGMSG2
> > +mv $LOGMSG2 $LOGMSG
> 
> Why are you messing with the $LOGMSG variables here?

This is only cosmetic. Using vim it displays the name of the temporary file and confusing the user with gitci2.XXXX instead of gitci.XXX is weird. Even using gitci as basename looks not good to me, but I left it for now.

Regards
Marcel
[PATCH] Make use of external editor work like CVS

The lines starting with `CG:' should be a trailer and not at the top of the message presented in the editor. Also extend the number of `-' up to 74 characters so that people know when they should start a new line. If it's not a merge and no commit text is given as parameter then add an extra empty line at the top. And don't forget to take care of the temporary files when a commit is unneeded or canceled.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

--- commit a2c4e793a4dfb21f43494ad90c7b887df10e1be2 tree cb61efa8a01400150162af9b0f3773f21d502fe9 parent 79f86b0174159f016540734ac18560566389b823 author Marcel Holtmann <marcel@holtmann.org> Sun, 08 May 2005 17:30:01 +0200 committer Marcel Holtmann <marcel@holtmann.org> Sun, 08 May 2005 17:30:01 +0200

 cg-commit |   61 +++++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 35 insertions(+), 26 deletions(-)
Show changes to diff +35 −26
Index: cg-commit
===================================================================
--- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
+++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
@@ -67,26 +67,10 @@
 
 LOGMSG=$(mktemp -t gitci.XXXXXX)
 LOGMSG2=$(mktemp -t gitci2.XXXXXX)
-echo CG: ---------------------------------------------------------- >>$LOGMSG
-echo CG: Lines beggining with CG: will be automatically removed     >>$LOGMSG
-echo CG:                                                            >>$LOGMSG
-if [ ! "$ignorecache" ]; then
-	if [ ! "${commitfiles[*]}" ]; then
-		echo 'Nothing to commit.' >&2
-		exit 2
-	fi
-	for file in "${commitfiles[@]}"; do
-		# Prepend a letter describing whether it's addition,
-		# removal or update. Or call git status on those files.
-		echo CG: $file >>$LOGMSG
-		[ "$msgs" ] && echo $file
-	done
-	echo CG: >>$LOGMSG
-fi
 
 if [ "$merging" ]; then
-	echo -n 'Merge with ' >>$LOGMSG
-	[ "$msgs" ] && echo -n 'Merge with '
+	echo -n "Merge with " >>$LOGMSG
+	[ "$msgs" ] && echo -n "Merge with "
 	[ -s .git/merging-sym ] || cp .git/merging .git/merging-sym
 	for sym in $(cat .git/merging-sym); do
 		uri=$(cat .git/branches/$sym)
@@ -94,30 +78,55 @@
 		echo "$uri" >>$LOGMSG
 		[ "$msgs" ] && echo "$uri"
 	done
-	echo >>$LOGMSG
+else
+	first=1
 fi
-first=1
+
 for msg in "${msgs[@]}"; do
 	if [ "$first" ]; then
 		first=
 	else
 		echo >>$LOGMSG
 	fi
-	echo $msg | fmt >>$LOGMSG
+	echo $msg | fmt -s -w 74 >>$LOGMSG
 done
+
+if [ "$first" ]; then
+	echo >>$LOGMSG
+fi
+
+echo "CG: ----------------------------------------------------------------------" >>$LOGMSG
+echo "CG: Enter Log.  Lines beginning with \`CG:' are removed automatically"      >>$LOGMSG
+if [ ! "$ignorecache" ]; then
+	if [ ! "${commitfiles[*]}" ]; then
+		rm $LOGMSG $LOGMSG2
+		die 'Nothing to commit.'
+	fi
+	echo "CG: " >>$LOGMSG
+	echo "CG: Modified Files:" >>$LOGMSG
+	for file in "${commitfiles[@]}"; do
+		# Prepend a letter describing whether it's addition,
+		# removal or update. Or call git status on those files.
+		echo "CG:    $file" >>$LOGMSG
+		[ "$msgs" ] && echo $file
+	done
+fi
+echo "CG: ----------------------------------------------------------------------" >>$LOGMSG
+
 cp $LOGMSG $LOGMSG2
 if tty -s; then
 	if ! [ "$msgs" ] || [ "$forceeditor" ]; then
-		${EDITOR:-vi} $LOGMSG2
+		${EDITOR:-vi} $LOGMSG
 	fi
-	if ! [ "$msgs" ] && ! [ $LOGMSG2 -nt $LOGMSG ]; then
-		die 'Commit message not modified, commit aborted'
+	if ! [ "$msgs" ] && ! [ $LOGMSG -nt $LOGMSG2 ]; then
+		rm $LOGMSG $LOGMSG2
+		die 'Commit message not modified, commit aborted.'
 	fi
 else
 	cat >>$LOGMSG2
 fi
-grep -v ^CG: $LOGMSG2 >$LOGMSG
-rm $LOGMSG2
+grep -v ^CG: $LOGMSG >$LOGMSG2
+mv $LOGMSG2 $LOGMSG
 
 if [ ! "$ignorecache" ]; then
 	if [ "$customfiles" ]; then
Petr Baudis· May 8, 2005, 15:56 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 05:43:10PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

> Hi Petr,
Hi,
Show 7 quoted lines
> > What is so special about 74 columns? Why not 75 (fmt default), or 72
> > (emails)?
> 
> I ended up with 74, because "CG" has only two letters instead of "CVS"
> which has three. And cg-log uses a prefix of four whitespaces. This
> leaves two free characters at the end of a line if your terminal uses a
> width of 80 characters. The decision was of cosmetic nature.
Isn't one free character enough?  I'll just stay with 75. :-)
Show 11 quoted lines
> > Also, I'd prefer the empty line to be always there in front of the CG:
> > stuff (two empty lines in case of merge - I want to encourage people to
> > keep possible details w.r.t. the merge separated by an empty line from
> > the merge information), and when reading it back cg-commit should strip
> > any trailing empty lines.
> 
> I think we should differentiate between the merges. There is no need for
> additional information if it is an automatic merge (no conflicts) and in
> general it makes no sense to open the editor (until forced). I wanted to
> address this later. And yes in case of a manual merge it is a good idea
> to add two extra empty lines at the top.

Not so. I frequently write a brief summary of what I'm actually merging. I'm not forcing you to do so too, but I personally think it's a good idea, and want to do it in the future too. :-)

> This is only cosmetic. Using vim it displays the name of the temporary
> file and confusing the user with gitci2.XXXX instead of gitci.XXX is
> weird. Even using gitci as basename looks not good to me, but I left it
> for now.

It boosts the patch size unnecessarily. It shouldn't be called gitci2 anyway... :-) Feel free to change the mktemp templates instead.

The gitci name comes all the way from the times where this command was usually triggered by 'git ci'.

Show 27 quoted lines
> Index: cg-commit
> ===================================================================
> --- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
> +++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
> @@ -94,30 +78,55 @@
>  		echo "$uri" >>$LOGMSG
>  		[ "$msgs" ] && echo "$uri"
>  	done
> -	echo >>$LOGMSG
> +else
> +	first=1
>  fi
> -first=1
> +
>  for msg in "${msgs[@]}"; do
>  	if [ "$first" ]; then
>  		first=
>  	else
>  		echo >>$LOGMSG
>  	fi
> -	echo $msg | fmt >>$LOGMSG
> +	echo $msg | fmt -s -w 74 >>$LOGMSG
>  done
> +
> +if [ "$first" ]; then
> +	echo >>$LOGMSG
> +fi
This mess is still here.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 16:15 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 9 quoted lines
> > > What is so special about 74 columns? Why not 75 (fmt default), or 72
> > > (emails)?
> > 
> > I ended up with 74, because "CG" has only two letters instead of "CVS"
> > which has three. And cg-log uses a prefix of four whitespaces. This
> > leaves two free characters at the end of a line if your terminal uses a
> > width of 80 characters. The decision was of cosmetic nature.
> 
> Isn't one free character enough?  I'll just stay with 75. :-)

I think it looks a little bit squeezed, but I don't mind at all. Maybe using 72 is a good idea. However it is only cosmetic and I can change it to use the fmt default.

Show 15 quoted lines
> > > Also, I'd prefer the empty line to be always there in front of the CG:
> > > stuff (two empty lines in case of merge - I want to encourage people to
> > > keep possible details w.r.t. the merge separated by an empty line from
> > > the merge information), and when reading it back cg-commit should strip
> > > any trailing empty lines.
> > 
> > I think we should differentiate between the merges. There is no need for
> > additional information if it is an automatic merge (no conflicts) and in
> > general it makes no sense to open the editor (until forced). I wanted to
> > address this later. And yes in case of a manual merge it is a good idea
> > to add two extra empty lines at the top.
> 
> Not so. I frequently write a brief summary of what I'm actually merging.
> I'm not forcing you to do so too, but I personally think it's a good
> idea, and want to do it in the future too. :-)

What do you think about a special flag for automatic merging (which makes the commit message say "Automatic merge") and a .cogitorc file like .cvsrc where you can choose the default method.

I am using a lot of temporary trees where I pull a lot of kernel subsystems together and I don't need that "feature" there.

Show 7 quoted lines
> > This is only cosmetic. Using vim it displays the name of the temporary
> > file and confusing the user with gitci2.XXXX instead of gitci.XXX is
> > weird. Even using gitci as basename looks not good to me, but I left it
> > for now.
> 
> It boosts the patch size unnecessarily. It shouldn't be called gitci2
> anyway... :-) Feel free to change the mktemp templates instead.

I will check what I can do, but I don't really care that much about the patch size ;)

> The gitci name comes all the way from the times where this command was
> usually triggered by 'git ci'.

I thought so. Is using cogito.XXXXXX and cogito.temp.XXXXX fine with you?

Show 29 quoted lines
> > Index: cg-commit
> > ===================================================================
> > --- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
> > +++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
> > @@ -94,30 +78,55 @@
> >  		echo "$uri" >>$LOGMSG
> >  		[ "$msgs" ] && echo "$uri"
> >  	done
> > -	echo >>$LOGMSG
> > +else
> > +	first=1
> >  fi
> > -first=1
> > +
> >  for msg in "${msgs[@]}"; do
> >  	if [ "$first" ]; then
> >  		first=
> >  	else
> >  		echo >>$LOGMSG
> >  	fi
> > -	echo $msg | fmt >>$LOGMSG
> > +	echo $msg | fmt -s -w 74 >>$LOGMSG
> >  done
> > +
> > +if [ "$first" ]; then
> > +	echo >>$LOGMSG
> > +fi
> 
> This mess is still here.

That is not mess. Think about it. If we have messages provided by -m we want an empty line between the merge message and the the first commit message. And we don't wanna have an extra empty line at the top if you provide a commit messages via -m.

Regards
Marcel
Petr Baudis· May 8, 2005, 17:12 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 06:15:36PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

> Hi Petr,
Hi,
Show 6 quoted lines
> What do you think about a special flag for automatic merging (which
> makes the commit message say "Automatic merge") and a .cogitorc file
> like .cvsrc where you can choose the default method.
> 
> I am using a lot of temporary trees where I pull a lot of kernel
> subsystems together and I don't need that "feature" there.

No problem with that per se, but please keep the configfile infrastructure and the automerge switch as separate patches from this one.

Show 10 quoted lines
> > > This is only cosmetic. Using vim it displays the name of the temporary
> > > file and confusing the user with gitci2.XXXX instead of gitci.XXX is
> > > weird. Even using gitci as basename looks not good to me, but I left it
> > > for now.
> > 
> > It boosts the patch size unnecessarily. It shouldn't be called gitci2
> > anyway... :-) Feel free to change the mktemp templates instead.
> 
> I will check what I can do, but I don't really care that much about the
> patch size ;)
But I do. :-)
Show 5 quoted lines
> > The gitci name comes all the way from the times where this command was
> > usually triggered by 'git ci'.
> 
> I thought so. Is using cogito.XXXXXX and cogito.temp.XXXXX fine with
> you?

No. I think it's useful (and doesn't cost us anything) to have the "owner" of the file denoted in the filename.

Show 34 quoted lines
> > > Index: cg-commit
> > > ===================================================================
> > > --- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
> > > +++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
> > > @@ -94,30 +78,55 @@
> > >  		echo "$uri" >>$LOGMSG
> > >  		[ "$msgs" ] && echo "$uri"
> > >  	done
> > > -	echo >>$LOGMSG
> > > +else
> > > +	first=1
> > >  fi
> > > -first=1
> > > +
> > >  for msg in "${msgs[@]}"; do
> > >  	if [ "$first" ]; then
> > >  		first=
> > >  	else
> > >  		echo >>$LOGMSG
> > >  	fi
> > > -	echo $msg | fmt >>$LOGMSG
> > > +	echo $msg | fmt -s -w 74 >>$LOGMSG
> > >  done
> > > +
> > > +if [ "$first" ]; then
> > > +	echo >>$LOGMSG
> > > +fi
> > 
> > This mess is still here.
> 
> That is not mess. Think about it. If we have messages provided by -m we
> want an empty line between the merge message and the the first commit
> message. And we don't wanna have an extra empty line at the top if you
> provide a commit messages via -m.
But, that's the current behaviour, isn't it?
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 17:17 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 10 quoted lines
> > What do you think about a special flag for automatic merging (which
> > makes the commit message say "Automatic merge") and a .cogitorc file
> > like .cvsrc where you can choose the default method.
> > 
> > I am using a lot of temporary trees where I pull a lot of kernel
> > subsystems together and I don't need that "feature" there.
> 
> No problem with that per se, but please keep the configfile
> infrastructure and the automerge switch as separate patches from this
> one.
It was never part of this patch. It is something I am thinking about.
Show 12 quoted lines
> > > > This is only cosmetic. Using vim it displays the name of the temporary
> > > > file and confusing the user with gitci2.XXXX instead of gitci.XXX is
> > > > weird. Even using gitci as basename looks not good to me, but I left it
> > > > for now.
> > > 
> > > It boosts the patch size unnecessarily. It shouldn't be called gitci2
> > > anyway... :-) Feel free to change the mktemp templates instead.
> > 
> > I will check what I can do, but I don't really care that much about the
> > patch size ;)
> 
> But I do. :-)

Sometime you don't have any other choice, because diff is not perfect. Do you wanna apply that patch or should I change the mktemp templates first?

Show 45 quoted lines
> > > The gitci name comes all the way from the times where this command was
> > > usually triggered by 'git ci'.
> > 
> > I thought so. Is using cogito.XXXXXX and cogito.temp.XXXXX fine with
> > you?
> 
> No. I think it's useful (and doesn't cost us anything) to have the
> "owner" of the file denoted in the filename.
> 
> > > > Index: cg-commit
> > > > ===================================================================
> > > > --- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
> > > > +++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
> > > > @@ -94,30 +78,55 @@
> > > >  		echo "$uri" >>$LOGMSG
> > > >  		[ "$msgs" ] && echo "$uri"
> > > >  	done
> > > > -	echo >>$LOGMSG
> > > > +else
> > > > +	first=1
> > > >  fi
> > > > -first=1
> > > > +
> > > >  for msg in "${msgs[@]}"; do
> > > >  	if [ "$first" ]; then
> > > >  		first=
> > > >  	else
> > > >  		echo >>$LOGMSG
> > > >  	fi
> > > > -	echo $msg | fmt >>$LOGMSG
> > > > +	echo $msg | fmt -s -w 74 >>$LOGMSG
> > > >  done
> > > > +
> > > > +if [ "$first" ]; then
> > > > +	echo >>$LOGMSG
> > > > +fi
> > > 
> > > This mess is still here.
> > 
> > That is not mess. Think about it. If we have messages provided by -m we
> > want an empty line between the merge message and the the first commit
> > message. And we don't wanna have an extra empty line at the top if you
> > provide a commit messages via -m.
> 
> But, that's the current behaviour, isn't it?

No it is not, because with my change the messages are at the top and before the CG: lines.

Regards
Marcel
Petr Baudis· May 8, 2005, 17:30 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 07:17:47PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

Show 8 quoted lines
> > > I will check what I can do, but I don't really care that much about the
> > > patch size ;)
> > 
> > But I do. :-)
> 
> Sometime you don't have any other choice, because diff is not perfect.
> Do you wanna apply that patch or should I change the mktemp templates
> first?

It looks like it'll be most painless when I just reinvent parts of your patch here locally and you can send me patches on top of that.

Show 39 quoted lines
> > > > > Index: cg-commit
> > > > > ===================================================================
> > > > > --- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
> > > > > +++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
> > > > > @@ -94,30 +78,55 @@
> > > > >  		echo "$uri" >>$LOGMSG
> > > > >  		[ "$msgs" ] && echo "$uri"
> > > > >  	done
> > > > > -	echo >>$LOGMSG
> > > > > +else
> > > > > +	first=1
> > > > >  fi
> > > > > -first=1
> > > > > +
> > > > >  for msg in "${msgs[@]}"; do
> > > > >  	if [ "$first" ]; then
> > > > >  		first=
> > > > >  	else
> > > > >  		echo >>$LOGMSG
> > > > >  	fi
> > > > > -	echo $msg | fmt >>$LOGMSG
> > > > > +	echo $msg | fmt -s -w 74 >>$LOGMSG
> > > > >  done
> > > > > +
> > > > > +if [ "$first" ]; then
> > > > > +	echo >>$LOGMSG
> > > > > +fi
> > > > 
> > > > This mess is still here.
> > > 
> > > That is not mess. Think about it. If we have messages provided by -m we
> > > want an empty line between the merge message and the the first commit
> > > message. And we don't wanna have an extra empty line at the top if you
> > > provide a commit messages via -m.
> > 
> > But, that's the current behaviour, isn't it?
> 
> No it is not, because with my change the messages are at the top and
> before the CG: lines.

I'm sorry but I still don't get what are you trying to say. :-) As far as I can see, the output will be the same, except that with to -m arguments, there won't be the extra newline for the merge message - and we agreed we want it, didn't we?

I'll just drop this chunk. :-)
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 17:40 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 6 quoted lines
> > Sometime you don't have any other choice, because diff is not perfect.
> > Do you wanna apply that patch or should I change the mktemp templates
> > first?
> 
> It looks like it'll be most painless when I just reinvent parts of your
> patch here locally and you can send me patches on top of that.

it is your choice. I can change that if you like. My latest version should apply cleanly against your current tree.

Show 44 quoted lines
> > > > > > Index: cg-commit
> > > > > > ===================================================================
> > > > > > --- f00d7589973e8ea65d2264f5fbac82e1b217dc8f/cg-commit  (mode:100755)
> > > > > > +++ cb61efa8a01400150162af9b0f3773f21d502fe9/cg-commit  (mode:100755)
> > > > > > @@ -94,30 +78,55 @@
> > > > > >  		echo "$uri" >>$LOGMSG
> > > > > >  		[ "$msgs" ] && echo "$uri"
> > > > > >  	done
> > > > > > -	echo >>$LOGMSG
> > > > > > +else
> > > > > > +	first=1
> > > > > >  fi
> > > > > > -first=1
> > > > > > +
> > > > > >  for msg in "${msgs[@]}"; do
> > > > > >  	if [ "$first" ]; then
> > > > > >  		first=
> > > > > >  	else
> > > > > >  		echo >>$LOGMSG
> > > > > >  	fi
> > > > > > -	echo $msg | fmt >>$LOGMSG
> > > > > > +	echo $msg | fmt -s -w 74 >>$LOGMSG
> > > > > >  done
> > > > > > +
> > > > > > +if [ "$first" ]; then
> > > > > > +	echo >>$LOGMSG
> > > > > > +fi
> > > > > 
> > > > > This mess is still here.
> > > > 
> > > > That is not mess. Think about it. If we have messages provided by -m we
> > > > want an empty line between the merge message and the the first commit
> > > > message. And we don't wanna have an extra empty line at the top if you
> > > > provide a commit messages via -m.
> > > 
> > > But, that's the current behaviour, isn't it?
> > 
> > No it is not, because with my change the messages are at the top and
> > before the CG: lines.
> 
> I'm sorry but I still don't get what are you trying to say. :-)
> As far as I can see, the output will be the same, except that with to -m
> arguments, there won't be the extra newline for the merge message - and
> we agreed we want it, didn't we?

The -m has nothing to do with the merge message. You can have one of them, but also both. Maybe I missed something in your latest changes.

If you want the extra newline(s) then it is a good idea to add something that strips heading and trailing empty lines from the final commit message, because otherwise it will be ugly if you don't enter extra text for the merge.

Regards
Marcel
Petr Baudis· May 8, 2005, 17:51 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 07:40:34PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

Show 9 quoted lines
> > > Sometime you don't have any other choice, because diff is not perfect.
> > > Do you wanna apply that patch or should I change the mktemp templates
> > > first?
> > 
> > It looks like it'll be most painless when I just reinvent parts of your
> > patch here locally and you can send me patches on top of that.
> 
> it is your choice. I can change that if you like. My latest version
> should apply cleanly against your current tree.

I've pushed my changes, please have a look at them. I think I've got everything important, but I might've forgot something.

> If you want the extra newline(s) then it is a good idea to add something
> that strips heading and trailing empty lines from the final commit
> message, because otherwise it will be ugly if you don't enter extra text
> for the merge.
Isn't that what I initially suggested? :-)
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 18:57 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 12 quoted lines
> > > > Sometime you don't have any other choice, because diff is not perfect.
> > > > Do you wanna apply that patch or should I change the mktemp templates
> > > > first?
> > > 
> > > It looks like it'll be most painless when I just reinvent parts of your
> > > patch here locally and you can send me patches on top of that.
> > 
> > it is your choice. I can change that if you like. My latest version
> > should apply cleanly against your current tree.
> 
> I've pushed my changes, please have a look at them. I think I've got
> everything important, but I might've forgot something.

look at the attached patch. We should use "fmt -s" to keep newlines that are inside the commit message and there is one unneeded empty CG: line.

I also put back in the "mess", because if there is no commit message provided via -m it gives us an initial empty line to start in. This is the same that CVS does and it makes the life inside vi a lot more easier.

The change (aka the "mess") looks crazy, but play with the different situations and see what it does.

Show 6 quoted lines
> > If you want the extra newline(s) then it is a good idea to add something
> > that strips heading and trailing empty lines from the final commit
> > message, because otherwise it will be ugly if you don't enter extra text
> > for the merge.
> 
> Isn't that what I initially suggested? :-)

But this hasn't been done so far. And I don't know any shell tool for this job, beside some crazy awk or sed stuff. However stripspace.c from git-tools can do this job.

Regards
Marcel
cg-commit: needs update
Show changes to diff +8 −3
Index: cg-commit
===================================================================
--- 6054af5ea0ef88077ad91131b0411dd10590b863/cg-commit  (mode:100755)
+++ uncommitted/cg-commit  (mode:100755)
@@ -80,17 +80,23 @@
 		[ "$msgs" ] && echo "$uri"
 	done
 	echo >>$LOGMSG
+else
+	first=1
 fi
-first=1
+
 for msg in "${msgs[@]}"; do
 	if [ "$first" ]; then
 		first=
 	else
 		echo >>$LOGMSG
 	fi
-	echo $msg | fmt >>$LOGMSG
+	echo $msg | fmt -s >>$LOGMSG
 done
 
+if [ "$first" ]; then
+	echo >>$LOGMSG
+fi
+
 cat >>$LOGMSG <<EOT
 CG: -----------------------------------------------------------------------
 CG: Lines beginning with the CG: prefix are removed automatically
@@ -108,7 +114,6 @@
 		echo "CG:    $file" >>$LOGMSG
 		[ "$msgs" ] && echo $file
 	done
-	echo "CG:" >>$LOGMSG
 fi
 echo "CG: -----------------------------------------------------------------------" >>$LOGMSG
 
Petr Baudis· May 8, 2005, 20:03 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 08:57:38PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

> Hi Petr,
Hello,
> look at the attached patch. We should use "fmt -s" to keep newlines that
> are inside the commit message and there is one unneeded empty CG: line.
thanks, fixed and pushed out.
> I also put back in the "mess", because if there is no commit message
> provided via -m it gives us an initial empty line to start in. This is
> the same that CVS does and it makes the life inside vi a lot more
> easier.

Well, I use 'O' to start editing. ;-) (Actually, I use the -m arguments extensively; the way it is now is how I always dreamt of it since I started using SCMs. Possibly in conjuction with -e to add some fancy stuff.)

Your way might be cunning, fast, or even clever, but it was certainly not clear, therefore not maintainable well. I tried to implement it in a simpler and more clear way. Does it behave as you want now?

Show 10 quoted lines
> > > If you want the extra newline(s) then it is a good idea to add something
> > > that strips heading and trailing empty lines from the final commit
> > > message, because otherwise it will be ugly if you don't enter extra text
> > > for the merge.
> > 
> > Isn't that what I initially suggested? :-)
> 
> But this hasn't been done so far. And I don't know any shell tool for
> this job, beside some crazy awk or sed stuff. However stripspace.c from
> git-tools can do this job.
#/bin/sh
leading=1
emptylines=0
while read line; do
        if ! [ "$line" ]; then
		[ "$leading" ] && continue
		emptylines=$(($emptylines + 1))
        else
		leading=0
                while [ $emptylines -gt 0 ]; do
                        echo ""
                        emptylines=$(($emptylines - 1))
                done
                echo $line
        fi
done
or something? (Based on someone else's script since I was too lazy. ;-)
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 20:26 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
> > look at the attached patch. We should use "fmt -s" to keep newlines that
> > are inside the commit message and there is one unneeded empty CG: line.
> 
> thanks, fixed and pushed out.
cool. Now I have everything I am used to from CVS, but ...
Show changes to diff +7 −5
@@ -113,7 +113,9 @@
                # TODO: Prepend a letter describing whether it's addition,
                # removal or update. Or call git status on those files.
                echo "CG:    $file" >>$LOGMSG
-               [ "$msgs" ] && echo $file
+               if [ "$msgs" ] && ! [ "$forceeditor" ]; then
+                       echo $file
+               fi
        done
 fi

There is no need to print out the files if we start the editor anyway.

@@ -122,10 +124,10 @@
 if tty -s; then
        if ! [ "$msgs" ] || [ "$forceeditor" ]; then
                ${EDITOR:-vi} $LOGMSG2
-       fi
-       if ! [ "$msgs" ] && ! [ $LOGMSG2 -nt $LOGMSG ]; then
-               rm $LOGMSG $LOGMSG2
-               die 'Commit message not modified, commit aborted'
+               if ! [ $LOGMSG2 -nt $LOGMSG ]; then
+                       rm $LOGMSG $LOGMSG2
+                       die 'Commit message not modified, commit aborted'
+               fi
        fi
 else

If you provide a commit message via -m and then close the editor without
changing it, it will commit the message. I think that will not be the
intention of the user.

> > I also put back in the "mess", because if there is no commit message
> > provided via -m it gives us an initial empty line to start in. This is
> > the same that CVS does and it makes the life inside vi a lot more
> > easier.
> 
> Well, I use 'O' to start editing. ;-) (Actually, I use the -m arguments
> extensively; the way it is now is how I always dreamt of it since I
> started using SCMs. Possibly in conjuction with -e to add some fancy
> stuff.)
> 
> Your way might be cunning, fast, or even clever, but it was certainly
> not clear, therefore not maintainable well. I tried to implement it in a
> simpler and more clear way. Does it behave as you want now?

What should I say ;)

I will do a little bit more tests, but it looks very good. Besides the
stuff above.

> > > > If you want the extra newline(s) then it is a good idea to add something
> > > > that strips heading and trailing empty lines from the final commit
> > > > message, because otherwise it will be ugly if you don't enter extra text
> > > > for the merge.
> > > 
> > > Isn't that what I initially suggested? :-)
> > 
> > But this hasn't been done so far. And I don't know any shell tool for
> > this job, beside some crazy awk or sed stuff. However stripspace.c from
> > git-tools can do this job.
> 
> #/bin/sh
> 
> leading=1
> emptylines=0
> while read line; do
>         if ! [ "$line" ]; then
> 		[ "$leading" ] && continue
> 		emptylines=$(($emptylines + 1))
>         else
> 		leading=0
>                 while [ $emptylines -gt 0 ]; do
>                         echo ""
>                         emptylines=$(($emptylines - 1))
>                 done
>                 echo $line
>         fi
> done
> 
> or something? (Based on someone else's script since I was too lazy. ;-)

I am not that script expert anymore. I do most stuff in C now and I am
very happy with it. Maybe someone else comes up with a clever way to
handle the following case:

/*
 * Remove empty lines from the beginning and end.
 *
 * Turn multiple consecutive empty lines into just one
 * empty line.
 */

Regards

Marcel
Petr Baudis· May 8, 2005, 21:08 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Sun, May 08, 2005 at 10:26:55PM CEST, I got a letter where Marcel Holtmann <marcel@holtmann.org> told me that...

> Hi Petr,
Hi,
Show 6 quoted lines
> > > look at the attached patch. We should use "fmt -s" to keep newlines that
> > > are inside the commit message and there is one unneeded empty CG: line.
> > 
> > thanks, fixed and pushed out.
> 
> cool. Now I have everything I am used to from CVS, but ...
Excellent.
Show 12 quoted lines
> @@ -113,7 +113,9 @@
>                 # TODO: Prepend a letter describing whether it's addition,
>                 # removal or update. Or call git status on those files.
>                 echo "CG:    $file" >>$LOGMSG
> -               [ "$msgs" ] && echo $file
> +               if [ "$msgs" ] && ! [ "$forceeditor" ]; then
> +                       echo $file
> +               fi
>         done
>  fi
> 
> There is no need to print out the files if we start the editor anyway.
Thanks, fixed.
Show 18 quoted lines
> @@ -122,10 +124,10 @@
>  if tty -s; then
>         if ! [ "$msgs" ] || [ "$forceeditor" ]; then
>                 ${EDITOR:-vi} $LOGMSG2
> -       fi
> -       if ! [ "$msgs" ] && ! [ $LOGMSG2 -nt $LOGMSG ]; then
> -               rm $LOGMSG $LOGMSG2
> -               die 'Commit message not modified, commit aborted'
> +               if ! [ $LOGMSG2 -nt $LOGMSG ]; then
> +                       rm $LOGMSG $LOGMSG2
> +                       die 'Commit message not modified, commit aborted'
> +               fi
>         fi
>  else
> 
> If you provide a commit message via -m and then close the editor without
> changing it, it will commit the message. I think that will not be the
> intention of the user.

Now, this is a pretty difficult question. The only other place in the Cogito toolkit which uses cg-commit -e is now cg-init when doing the initial commit - and you definitively want to commit even if the message was not modified in that case. Also, what if you want to just review how the -m stuff flows like before committing?

OTOH, we might want to stay consistent in behaviour and always abandon action when the file was not modified (except for the initial commit). Perhaps some -E for that? Other thoughts?

Show 6 quoted lines
> /*
>  * Remove empty lines from the beginning and end.
>  *
>  * Turn multiple consecutive empty lines into just one
>  * empty line.
>  */

Bah, that's even easier when you want to squeeze the empty lines inside of the commit message. I don't, though.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Marcel Holtmann· May 8, 2005, 21:19 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 28 quoted lines
> > @@ -122,10 +124,10 @@
> >  if tty -s; then
> >         if ! [ "$msgs" ] || [ "$forceeditor" ]; then
> >                 ${EDITOR:-vi} $LOGMSG2
> > -       fi
> > -       if ! [ "$msgs" ] && ! [ $LOGMSG2 -nt $LOGMSG ]; then
> > -               rm $LOGMSG $LOGMSG2
> > -               die 'Commit message not modified, commit aborted'
> > +               if ! [ $LOGMSG2 -nt $LOGMSG ]; then
> > +                       rm $LOGMSG $LOGMSG2
> > +                       die 'Commit message not modified, commit aborted'
> > +               fi
> >         fi
> >  else
> > 
> > If you provide a commit message via -m and then close the editor without
> > changing it, it will commit the message. I think that will not be the
> > intention of the user.
> 
> Now, this is a pretty difficult question. The only other place in the
> Cogito toolkit which uses cg-commit -e is now cg-init when doing the
> initial commit - and you definitively want to commit even if the message
> was not modified in that case. Also, what if you want to just review
> how the -m stuff flows like before committing?
> 
> OTOH, we might want to stay consistent in behaviour and always abandon
> action when the file was not modified (except for the initial commit).
> Perhaps some -E for that? Other thoughts?

I think using -E to commit even when you don't modify the commit message is a good idea. The alternative way is to ask the user like CVS does.

Show 9 quoted lines
> > /*
> >  * Remove empty lines from the beginning and end.
> >  *
> >  * Turn multiple consecutive empty lines into just one
> >  * empty line.
> >  */
> 
> Bah, that's even easier when you want to squeeze the empty lines inside
> of the commit message. I don't, though.

You can do that with "cat -s", I know. But then you still have to look at the first and the last line and delete it if they are empty.

I think it is a good idea to squeeze empty lines, because multi empty lines are not useful for commit messages anyway. What do you think?

Regards
Marcel
Edgar Toernig· May 9, 2005, 03:28 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Petr Baudis wrote:
Show 5 quoted lines
>
> > +               if ! [ $LOGMSG2 -nt $LOGMSG ]; then
> > +                       rm $LOGMSG $LOGMSG2
> > +                       die 'Commit message not modified, commit aborted'
> > +               fi

Just in case you come to a conclusion some day, how about changing the if-test to

	if cmp -s $LOGMSG LOGMSG2; then
?  :-)  IMHO much better then comparing only the date.
Ciao, ET.
Petr Baudis· May 9, 2005, 07:33 UTC · re: Edgar Toernig · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Dear diary, on Mon, May 09, 2005 at 05:28:14AM CEST, I got a letter where Edgar Toernig <froese@gmx.de> told me that...

Show 15 quoted lines
> Petr Baudis wrote:
> >
> > > +               if ! [ $LOGMSG2 -nt $LOGMSG ]; then
> > > +                       rm $LOGMSG $LOGMSG2
> > > +                       die 'Commit message not modified, commit aborted'
> > > +               fi
> 
> Just in case you come to a conclusion some day, how about changing the
> if-test to
> 
> 	if cmp -s $LOGMSG LOGMSG2; then
> 
> ?  :-)  IMHO much better then comparing only the date.
> 
> Ciao, ET.

Much, much worse. What if I really actually do not want to change anything in the merge message or the series of -m's? Ok, :x didn't work now since we cannot know. But now, :wq won't do either, and you actually need to do some silly dummy change now.

I think we should really ask the user as CVS, as Marcel (or whoever) suggested.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Sean· May 8, 2005, 21:46 UTC · re: Marcel Holtmann · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

On Sun, May 8, 2005 4:26 pm, Marcel Holtmann said:
Show 6 quoted lines
> /*
>  * Remove empty lines from the beginning and end.
>  *
>  * Turn multiple consecutive empty lines into just one
>  * empty line.
>  */
sed ' 1{:a;s/^[ \t]*$//;T;N;s/\n//;ta}
      /^[ \t]*$/{:b;$d;N;s/\n[ \t]*$//;tb}'  filename
There's probably shorter... but it's mothers day.. time to go!

Cheers, Sean

Marcel Holtmann· May 8, 2005, 21:43 UTC · re: Petr Baudis · lore

Re: [PATCH Cogito] Make use of external editor work like CVS

Hi Petr,
Show 19 quoted lines
> #/bin/sh
> 
> leading=1
> emptylines=0
> while read line; do
>         if ! [ "$line" ]; then
> 		[ "$leading" ] && continue
> 		emptylines=$(($emptylines + 1))
>         else
> 		leading=0
>                 while [ $emptylines -gt 0 ]; do
>                         echo ""
>                         emptylines=$(($emptylines - 1))
>                 done
>                 echo $line
>         fi
> done
> 
> or something? (Based on someone else's script since I was too lazy. ;-)
Show changes to diff +1 −1
@@ -134,7 +134,7 @@
 else
        cat >>$LOGMSG2
 fi
-grep -v ^CG: $LOGMSG2 >$LOGMSG
+grep -v ^CG: $LOGMSG2 | sed '/./,${/./b;:a;$d;N;/\n$/ba;b;};d' >$LOGMSG
 rm $LOGMSG2
 
 
If you don't wanna squeeze then you can do it with a one-line in sed.

Regards

Marcel

← back to recent threads