Make use of external editor work like CVS
PATCH 1/1 Make use of external editor work like CVS
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.
---
commit 895bcd02ecc96bed1d35275def6dca1ca6f20e5f
tree be440e169fa3b5ec5450fa9574cd8789b0e3ab20
parent 64142a39e7a6701e69654a930de86a9fe296f8a0
author Marcel Holtmann <[email protected]> Sun, 08 May 2005 16:58:50 +0200 committer Marcel Holtmann <[email protected]> Sun, 08 May 2005 16:58:50 +0200
cg-commit | 63 ++++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 37 insertions(+), 26 deletions(-)
cg-commit (mode:100755) +37 -26
@@ -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
Quoted 6 lines · Marcel Holtmann
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
Dear diary, on Sun, May 08, 2005 at 05:02:30PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 1 line
Hi Petr,
Hi,
Quoted 3 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.
Quoted 10 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 <[email protected]>
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.
cg-commit (mode:100755) line 67
Quoted 9 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +2
-2if [ "$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. ;-)
Quoted 9 lines
cp $LOGMSG $LOGMSG2
if tty -s; thencg-commit (mode:100755) +4
-2if ! [ "$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.'
cg-commit (mode:100755) line 123
Quoted 10 lines
cg-commit (mode:100755) +4
-3+ 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?
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 5 lines
Quoted 3 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.
Quoted 9 lines
Quoted 9 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.
Quoted 4 lines
Quoted 1 line
Signed-off-by Marcel Holtmann <[email protected]>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.
Quoted 5 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.
Quoted 4 lines
Quoted 4 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +0
-0
Quoted 8 lines
cg-commit (mode:100755)
Quoted 5 lines
if [ "$merging" ]; then
cg-commit (mode:100755) +2
-2- 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 ;)
Quoted 13 lines
Quoted 13 lines
cp $LOGMSG $LOGMSG2
if tty -s; thencg-commit (mode:100755) +5
-3if ! [ "$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
Quoted 8 lines
cg-commit (mode:100755)
Quoted 6 lines
cg-commit (mode:100755) +3
-2+ cat >>$LOGMSG fi -grep -v ^CG: $LOGMSG2 >$LOGMSG -rm $LOGMSG2 +grep -v ^CG: $LOGMSG >$LOGMSG2 +mv $LOGMSG2 $LOGMSGWhy 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.
---
commit a2c4e793a4dfb21f43494ad90c7b887df10e1be2
tree cb61efa8a01400150162af9b0f3773f21d502fe9
parent 79f86b0174159f016540734ac18560566389b823
author Marcel Holtmann <[email protected]> Sun, 08 May 2005 17:30:01 +0200 committer Marcel Holtmann <[email protected]> Sun, 08 May 2005 17:30:01 +0200
cg-commit | 61 +++++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 35 insertions(+), 26 deletions(-)
cg-commit (mode:100755) +35 -26
@@ -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
Dear diary, on Sun, May 08, 2005 at 05:43:10PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 1 line
Hi Petr,
Hi,
Quoted 7 lines
Quoted 2 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. :-)
Quoted 11 lines
Quoted 5 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. :-)
Quoted 4 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.
The gitci name comes all the way from the times where this command was usually triggered by 'git ci'.
Quoted 17 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +3
-2@@ -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=
cg-commit (mode:100755) line 96
Quoted 10 lines
cg-commit (mode:100755) +5
-1else 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.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 9 lines
Quoted 7 lines
Quoted 2 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.
Quoted 12 lines
Quoted 11 lines
Quoted 5 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.
Quoted 3 lines
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.
Quoted 7 lines
Quoted 4 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 ;)
Quoted 2 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?
Quoted 21 lines
Quoted 21 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +3
-3@@ -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
Quoted 8 lines
cg-commit (mode:100755) line 96
Quoted 6 lines
cg-commit (mode:100755) +5
-0+ echo $msg | fmt -s -w 74 >>$LOGMSG done + +if [ "$first" ]; then + echo >>$LOGMSG +fiThis 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
Dear diary, on Sun, May 08, 2005 at 06:15:36PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 1 line
Hi Petr,
Hi,
Quoted 6 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.
Quoted 10 lines
Quoted 7 lines
Quoted 4 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. :-)
Quoted 5 lines
Quoted 2 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.
Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +3
-3@@ -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 >>$LOGMSGQuoted 8 lines
cg-commit (mode:100755) line 96
Quoted 6 lines
cg-commit (mode:100755) +5
-0+ echo $msg | fmt -s -w 74 >>$LOGMSG done + +if [ "$first" ]; then + echo >>$LOGMSG +fiThis mess is still here.
Quoted 4 lines
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?
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 10 lines
Quoted 6 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.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 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.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
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?
Quoted 39 lines
Quoted 5 lines
Quoted 2 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.
Quoted 30 lines
Quoted 29 lines
Quoted 17 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +3
-2@@ -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=cg-commit (mode:100755) line 96
Quoted 10 lines
cg-commit (mode:100755) +5
-1else echo >>$LOGMSG fi - echo $msg | fmt >>$LOGMSG + echo $msg | fmt -s -w 74 >>$LOGMSG done + +if [ "$first" ]; then + echo >>$LOGMSG +fiThis mess is still here.
Quoted 6 lines
Quoted 4 lines
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
Dear diary, on Sun, May 08, 2005 at 07:17:47PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 8 lines
Quoted 4 lines
Quoted 2 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.
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines
Quoted 21 lines
Quoted 21 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +3
-3@@ -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 >>$LOGMSGQuoted 8 lines
cg-commit (mode:100755) line 96
Quoted 6 lines
cg-commit (mode:100755) +5
-0+ echo $msg | fmt -s -w 74 >>$LOGMSG done + +if [ "$first" ]; then + echo >>$LOGMSG +fiThis 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.
Quoted 4 lines
Quoted 1 line
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. :-)
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 6 lines
Quoted 3 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.
Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
Index: cg-commit
===================================================================cg-commit (mode:100755) +3
-3@@ -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 >>$LOGMSGQuoted 8 lines
cg-commit (mode:100755) line 96
Quoted 6 lines
cg-commit (mode:100755) +5
-0+ echo $msg | fmt -s -w 74 >>$LOGMSG done + +if [ "$first" ]; then + echo >>$LOGMSG +fiThis mess is still here.
Quoted 4 lines
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?
Quoted 7 lines
Quoted 2 lines
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
Dear diary, on Sun, May 08, 2005 at 07:40:34PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 9 lines
Quoted 6 lines
Quoted 3 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.
Quoted 4 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? :-)
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 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?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
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.
Quoted 6 lines
Quoted 4 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
Index: cg-commit
===================================================================
cg-commit (mode:100755) +8 -3
@@ -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
Dear diary, on Sun, May 08, 2005 at 08:57:38PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 1 line
Hi Petr,
Hello,
Quoted 2 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.
Quoted 4 lines
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?
Quoted 10 lines
Quoted 6 lines
Quoted 4 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.cfrom 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
fidone
or something? (Based on someone else's script since I was too lazy. ;-)
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 4 lines
Quoted 2 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 ...
@@ -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.
Quoted 5 lines
Quoted 4 lines
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.
Quoted 8 lines
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.
Quoted 27 lines
Quoted 10 lines
Quoted 6 lines
Quoted 4 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.cfrom git-tools can do this job.#/bin/sh
leading=1
emptylines=0
while read line; doif ! [ "$line" ]; then [ "$leading" ] && continue emptylines=$(($emptylines + 1)) else leading=0 while [ $emptylines -gt 0 ]; do echo "" emptylines=$(($emptylines - 1)) done echo $line fi
Quoted 3 lines
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
Dear diary, on Sun, May 08, 2005 at 10:26:55PM CEST, I got a letter where Marcel Holtmann <[email protected]> told me that...
Quoted 1 line
Hi Petr,
Hi,
Quoted 6 lines
Quoted 4 lines
Quoted 2 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.
Quoted 11 lines
(quoted diff) +3
-1@@ -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
Quoted 1 line
There is no need to print out the files if we start the editor anyway.
Thanks, fixed.
Quoted 15 lines
(quoted diff) +4
-4@@ -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
Quoted 3 lines
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?
Quoted 6 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.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Hi Petr,
Quoted 25 lines
Quoted 15 lines
(quoted diff) +4
-4@@ -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 elseQuoted 3 lines
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?
Quoted 3 lines
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.
Quoted 9 lines
Quoted 6 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
Quoted 5 lines · Petr Baudis
Review
Quoted 5 lines
(quoted diff) +4
-0+ 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.
Dear diary, on Mon, May 09, 2005 at 05:28:14AM CEST, I got a letter where Edgar Toernig <[email protected]> told me that...
Quoted 7 lines
Quoted 5 lines · Petr Baudis
Review
Quoted 5 lines
(quoted diff) +4
-0+ if ! [ $LOGMSG2 -nt $LOGMSG ]; then + rm $LOGMSG $LOGMSG2 + die 'Commit message not modified, commit aborted' + fi
Quoted 8 lines
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.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Quoted 6 lines · Marcel Holtmann
/*
* 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}' filenameThere's probably shorter... but it's mothers day.. time to go!
Cheers,
Sean
Hi Petr,
Quoted 16 lines
#/bin/sh
leading=1
emptylines=0
while read line; doif ! [ "$line" ]; then [ "$leading" ] && continue emptylines=$(($emptylines + 1)) else leading=0 while [ $emptylines -gt 0 ]; do echo "" emptylines=$(($emptylines - 1)) done echo $line fi
Quoted 3 lines
done
or something? (Based on someone else's script since I was too lazy. ;-)
@@ -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