* [PATCH Cogito] Make use of external editor work like CVS
@ 2005-05-08 15:02 Marcel Holtmann
2005-05-08 15:24 ` Sean
2005-05-08 15:25 ` Petr Baudis
0 siblings, 2 replies; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 15:02 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
[-- Attachment #1: Type: text/plain, Size: 205 bytes --]
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
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3739 bytes --]
[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(-)
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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 15:02 [PATCH Cogito] Make use of external editor work like CVS Marcel Holtmann
@ 2005-05-08 15:24 ` Sean
2005-05-08 15:25 ` Petr Baudis
1 sibling, 0 replies; 21+ messages in thread
From: Sean @ 2005-05-08 15:24 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Petr Baudis, GIT Mailing List
On Sun, May 8, 2005 11:02 am, Marcel Holtmann said:
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 15:02 [PATCH Cogito] Make use of external editor work like CVS Marcel Holtmann
2005-05-08 15:24 ` Sean
@ 2005-05-08 15:25 ` Petr Baudis
2005-05-08 15:43 ` Marcel Holtmann
1 sibling, 1 reply; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 15:25 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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.
> [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.
> 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. ;-)
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 15:25 ` Petr Baudis
@ 2005-05-08 15:43 ` Marcel Holtmann
2005-05-08 15:56 ` Petr Baudis
0 siblings, 1 reply; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 15:43 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
[-- Attachment #1: Type: text/plain, Size: 3407 bytes --]
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.
>
> ...and I've just pushed more modifications. I'm so evil.
attached is another version of the patch.
> > [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.
> 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.
> > 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 ;)
> > 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
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3782 bytes --]
[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(-)
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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 15:43 ` Marcel Holtmann
@ 2005-05-08 15:56 ` Petr Baudis
2005-05-08 16:15 ` Marcel Holtmann
0 siblings, 1 reply; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 15:56 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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,
> > 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. :-)
> > 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'.
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 15:56 ` Petr Baudis
@ 2005-05-08 16:15 ` Marcel Holtmann
2005-05-08 17:12 ` Petr Baudis
0 siblings, 1 reply; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 16:15 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
Hi Petr,
> > > 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.
> > > 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.
> > 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?
> > 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 16:15 ` Marcel Holtmann
@ 2005-05-08 17:12 ` Petr Baudis
2005-05-08 17:17 ` Marcel Holtmann
0 siblings, 1 reply; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 17:12 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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,
> 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.
> > > 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. :-)
> > 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?
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 17:12 ` Petr Baudis
@ 2005-05-08 17:17 ` Marcel Holtmann
2005-05-08 17:30 ` Petr Baudis
0 siblings, 1 reply; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 17:17 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
Hi Petr,
> > 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.
> > > > 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?
> > > 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 17:17 ` Marcel Holtmann
@ 2005-05-08 17:30 ` Petr Baudis
2005-05-08 17:40 ` Marcel Holtmann
0 siblings, 1 reply; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 17:30 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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...
> > > 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.
> > > > > 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 17:30 ` Petr Baudis
@ 2005-05-08 17:40 ` Marcel Holtmann
2005-05-08 17:51 ` Petr Baudis
0 siblings, 1 reply; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 17:40 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
Hi Petr,
> > 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.
> > > > > > 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 17:40 ` Marcel Holtmann
@ 2005-05-08 17:51 ` Petr Baudis
2005-05-08 18:57 ` Marcel Holtmann
0 siblings, 1 reply; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 17:51 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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...
> > > 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 17:51 ` Petr Baudis
@ 2005-05-08 18:57 ` Marcel Holtmann
2005-05-08 20:03 ` Petr Baudis
0 siblings, 1 reply; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 18:57 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]
Hi Petr,
> > > > 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.
> > 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
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 908 bytes --]
cg-commit: needs update
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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 18:57 ` Marcel Holtmann
@ 2005-05-08 20:03 ` Petr Baudis
2005-05-08 20:26 ` Marcel Holtmann
2005-05-08 21:43 ` Marcel Holtmann
0 siblings, 2 replies; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 20:03 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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?
> > > 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 20:03 ` Petr Baudis
@ 2005-05-08 20:26 ` Marcel Holtmann
2005-05-08 21:08 ` Petr Baudis
2005-05-08 21:46 ` Sean
2005-05-08 21:43 ` Marcel Holtmann
1 sibling, 2 replies; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 20:26 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
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 ...
@@ -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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 20:26 ` Marcel Holtmann
@ 2005-05-08 21:08 ` Petr Baudis
2005-05-08 21:19 ` Marcel Holtmann
2005-05-09 3:28 ` Edgar Toernig
2005-05-08 21:46 ` Sean
1 sibling, 2 replies; 21+ messages in thread
From: Petr Baudis @ 2005-05-08 21:08 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: GIT Mailing List
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,
> > > 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.
> @@ -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.
> @@ -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?
> /*
> * 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 21:08 ` Petr Baudis
@ 2005-05-08 21:19 ` Marcel Holtmann
2005-05-09 3:28 ` Edgar Toernig
1 sibling, 0 replies; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 21:19 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
Hi Petr,
> > @@ -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.
> > /*
> > * 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
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 21:08 ` Petr Baudis
2005-05-08 21:19 ` Marcel Holtmann
@ 2005-05-09 3:28 ` Edgar Toernig
2005-05-09 7:33 ` Petr Baudis
1 sibling, 1 reply; 21+ messages in thread
From: Edgar Toernig @ 2005-05-09 3:28 UTC (permalink / raw)
To: Petr Baudis; +Cc: Marcel Holtmann, GIT Mailing List
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.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-09 3:28 ` Edgar Toernig
@ 2005-05-09 7:33 ` Petr Baudis
0 siblings, 0 replies; 21+ messages in thread
From: Petr Baudis @ 2005-05-09 7:33 UTC (permalink / raw)
To: Edgar Toernig; +Cc: Marcel Holtmann, GIT Mailing List
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...
> 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 20:26 ` Marcel Holtmann
2005-05-08 21:08 ` Petr Baudis
@ 2005-05-08 21:46 ` Sean
1 sibling, 0 replies; 21+ messages in thread
From: Sean @ 2005-05-08 21:46 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Petr Baudis, GIT Mailing List
On Sun, May 8, 2005 4:26 pm, Marcel Holtmann said:
> /*
> * 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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH Cogito] Make use of external editor work like CVS
2005-05-08 20:03 ` Petr Baudis
2005-05-08 20:26 ` Marcel Holtmann
@ 2005-05-08 21:43 ` Marcel Holtmann
1 sibling, 0 replies; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 21:43 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
Hi Petr,
> #/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. ;-)
@@ -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
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH Cogito] Make use of external editor work like CVS
@ 2005-05-08 1:10 Marcel Holtmann
0 siblings, 0 replies; 21+ messages in thread
From: Marcel Holtmann @ 2005-05-08 1:10 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
[-- Attachment #1: Type: text/plain, Size: 171 bytes --]
Hi Petr,
I like to extend the work from Pavel and make the cg-commit really work
like we know it from CVS. Please consider applying the attached patch.
Regards
Marcel
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3416 bytes --]
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 via the command
line add an extra empty line at the top.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
commit ad5cabd7130fc180aed0c364d4014abb49f374b0
tree ca866565063dcd89204e747e8aa0fcb483d14841
parent 09f6584daa060eda641a8e727698f935e0960e9c
author Marcel Holtmann <marcel@holtmann.org> Sun, 08 May 2005 03:03:53 +0200
committer Marcel Holtmann <marcel@holtmann.org> Sun, 08 May 2005 03:03:53 +0200
cg-commit | 55 +++++++++++++++++++++++++++++++------------------------
1 files changed, 31 insertions(+), 24 deletions(-)
Index: cg-commit
===================================================================
--- 5d7e8450d626a4e99f8222378a6818d03a797864/cg-commit (mode:100755)
+++ ca866565063dcd89204e747e8aa0fcb483d14841/cg-commit (mode:100755)
@@ -61,24 +61,9 @@
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
- done
- echo CG: >>$LOGMSG
-fi
if [ "$merging" ]; then
- echo -n 'Merge with ' >>$LOGMSG
+ echo -n "Merge with " >>$LOGMSG
[ -s .git/merging-sym ] || cp .git/merging .git/merging-sym
for sym in $(cat .git/merging-sym); do
uri=$(cat .git/branches/$sym)
@@ -86,28 +71,50 @@
echo "$uri" >>$LOGMSG
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
+ 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
+ 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
+ [ $LOGMSG -nt $LOGMSG2 ] || die 'Commit message not modified, commit aborted.'
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
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2005-05-09 7:26 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-08 15:02 [PATCH Cogito] Make use of external editor work like CVS Marcel Holtmann
2005-05-08 15:24 ` Sean
2005-05-08 15:25 ` Petr Baudis
2005-05-08 15:43 ` Marcel Holtmann
2005-05-08 15:56 ` Petr Baudis
2005-05-08 16:15 ` Marcel Holtmann
2005-05-08 17:12 ` Petr Baudis
2005-05-08 17:17 ` Marcel Holtmann
2005-05-08 17:30 ` Petr Baudis
2005-05-08 17:40 ` Marcel Holtmann
2005-05-08 17:51 ` Petr Baudis
2005-05-08 18:57 ` Marcel Holtmann
2005-05-08 20:03 ` Petr Baudis
2005-05-08 20:26 ` Marcel Holtmann
2005-05-08 21:08 ` Petr Baudis
2005-05-08 21:19 ` Marcel Holtmann
2005-05-09 3:28 ` Edgar Toernig
2005-05-09 7:33 ` Petr Baudis
2005-05-08 21:46 ` Sean
2005-05-08 21:43 ` Marcel Holtmann
-- strict thread matches above, loose matches on Subject: below --
2005-05-08 1:10 Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).