Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-04 Thread Marco Stornelli
2012/9/4 Junio C Hamano :
> Marco Stornelli  writes:
>
>> kernel, load the patch and send, really easy. So I don't think it's a
>> regression, it's only a change in the work flow.
>
> Any change that forces the user to change an established work flow
> supporteed by the existing tool we gave them _is_ a regression, even
> if the person who forces that change believes the new way is better.

A change of this kind in external script like this, it isn't an
API/ABI change for me, your sentence is really opinable. With this
policy every application can't be changed to improve them (note here
we are talking about to change a work flow not to remove a feature).
If for you it is a problem, we can close this never ending thread
here. I'm happy with my script.

Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-04 Thread Marco Stornelli

Il 04/09/2012 17:49, Junio C Hamano ha scritto:

Marco Stornelli  writes:


2012/9/4 Junio C Hamano :


I would expect, at least when you are responding to an existing
message, some of them are filled already (and if so, I think appp.sh
wants to know exactly how, for example, has RFC2047 quoting already
applied, or are we supposed to write in UTF-8 and let Thunderbird
massage the contents when we give the file back to it?), and also
there would appear In-Reply-To: field already filled (possibly there
may be References: as well).


Message reply is out of scope of my patch. The goal here is send a
patch, so the execution flow is to open a new message,
clik on external editor (configured properly), select patch file and
send. It was the scope of the old script and it is the scope of my
patch.


I certainly can understand that you updated the script for that use
case and that use case only, but given that the original tries very
hard to preserve:

  - what was in $HEADERS (by only replacing Subject);
  - the recipients CC'ed in $HEADERS (by grabbing them into $CCS); and
  - the body of the message in $BODY (i.e. what came after $SEP),

I find it hard to believe that it was meant to work on a freshly
created empty message and nothing else.  If people were depending on
the recipients listed on Cc that are taken from $1 to be preserved,
your patch will introduce a regression for them, no?



I think all the process is different. Current script rely on the user to 
fill Cc: and To: in message composition window, it does a union of what 
found in commit message as signed-off-by (adding own address in cc?!) 
and Cc (usually not filled in the commit message and we should even 
count acked-by, tested-by and so on). My vision of things: the user can 
create a patch *already* with all information using --to and --cc. If 
you want to add optional addresses, you can of course add them in the 
composition window. In addition, with this approach is really easy to 
use external script as get_maintainer.pl of linux kernel, load the patch 
and send, really easy. So I don't think it's a regression, it's only a 
change in the work flow.


Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-04 Thread Marco Stornelli
2012/9/4 Junio C Hamano :
> Marco Stornelli  writes:
>
>> I don't have thunderbird now but actually it's really simple:
>>
>> Subject:
>> To:
>> Cc:
>> $SEP
>
> The above is not a very useful "example" to advance this discussion,
> I have to say.  For one, where is your Oggetto?

1) Where is your Oggetto?
I used english template simply because the question was about position
of each statement, but with translation the positions are the same.

2) Are these fields the only ones you will ever see?
No, the template is dynamic according to the settings of plug-in
"external editor". You can have
Subject, To, Cc, Ccn, In reply to, discussion group (please see
external editor for details).

3)  Are they always empty?
Yes. If they are empty, nothing happens actually. I mean, if you have
the field Cc: empty, in the message composition
Thunderbird will use an empty Cc: line, but no problem in sending.

>
> I would expect, at least when you are responding to an existing
> message, some of them are filled already (and if so, I think appp.sh
> wants to know exactly how, for example, has RFC2047 quoting already
> applied, or are we supposed to write in UTF-8 and let Thunderbird
> massage the contents when we give the file back to it?), and also
> there would appear In-Reply-To: field already filled (possibly there
> may be References: as well).

Message reply is out of scope of my patch. The goal here is send a
patch, so the execution flow is to open a new message,
clik on external editor (configured properly), select patch file and
send. It was the scope of the old script and it is the scope of my
patch. Usually you don't send a patch as reply, however even if you
want to send patch as proof-of-concept as reply, there is no
problem, you can copy&paste the patch body. The script, instead, is
very useful to load all patch info, pre-formatting it and filling with
all To: and Cc. So IMHO the in-reply-to case is simply overkilling for
this script. In addition, I think all this discussion is overkilling
for a simple script like that, if a thing can be improved ok I agree
to improve it, but what are we talking about? About a little script
that is only an external utility for this project, not a core
functionality.

Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-03 Thread Marco Stornelli
2012/9/3 Junio C Hamano :
> Marco Stornelli  writes:
>
>> I tried the Johannes's script, but it seems it doesn't work well with
>> the pattern of format-patch (To: ,\n   ,\n
>> ). The multilines are not well managed.
>
> I am guessing that the reason why Jonahhes's "copy our headers out
> with continuation lines intact" approach does not work is because
> Thunderbird does not want to see its own header part (i.e. that
> which comes before that $SEP) contain RFC-2822 style continuation
> lines.
>
> Can you grab a typical input (i.e. the contents of what is passed as
> $1 to the appp.sh script) and show us how it looks like here so that
> we can take a look?  It would be fine to paste the contents, but we
> might want to protect it from MUA by doing an attachment or a
> pastebin URL.

I don't have thunderbird now but actually it's really simple:

Subject:
To:
Cc:
$SEP

Each data must be in a signle line, for example "Cc: ,.,"

>
> It appears that the original script tries very hard to keep the
> Subject: line at the beginning, but I am not sure if that is because
> Thunderbird wants to read its "$1" that way, or it is just that
> original appp.sh script happened to be written that way without real
> reason.  If I were updating this script, what I would do would be
> more like:

Ok, good coding then.

Regards,

Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6] Thunderbird: fix appp.sh format problems

2012-09-03 Thread Marco Stornelli
The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not English;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded from Cc used in the commit message
instead of using the Cc field filled by format-patch in the email
header.

Added comments for point 1), added parsing of To: for point 2) and
added parsing of Cc: in the email header for point 3), removing the
Cc: parsing from commit message.

Signed-off-by: Marco Stornelli 
---

v6: replaced single quotas with double quotas in perl embedded script
v5: fixed comments by Junio C Hamano
v4: create a tmp file to allow correct perl parsing
v3: parse only To: and Cc: in the email header, fix some comments
v2: changed the commit message to reflect better the script implementation
v1: first draft

 contrib/thunderbird-patch-inline/appp.sh |   25 +
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..5e4e892 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
 CONFFILE=~/.appprc
 
 SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,31 @@ fi
 cd - > /dev/null
 
 SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
 BODY=`sed -e "1,/${SEP}/d" $1`
 CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
 DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
+PATCHTMP="${PATCH}.tmp"
+
+sed '/^$/q' "${PATCH}" > "${PATCHTMP}"
+
+export PATCHTMP
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{"PATCHTMP"}; $text=;
+close FILE; $addr = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{"PATCHTMP"}; $text=;
+close FILE; $addr = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
 
-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+rm -f ${PATCHTMP}
 
+# Change Subject: before next line according to Thunderbird language
+# for example to translate in Italian:
+# SUBJECT=`echo $SUBJECT | sed -e 's/^Subject:/Oggetto:/g'`
 echo "$SUBJECT" > $1
+# Change To: according to Thunderbird language
+echo "To: $TO" >> $1
 echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
 echo "$SEP" >> $1
 
 echo "$CMT_MSG" >> $1
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-03 Thread Marco Stornelli

Il 02/09/2012 22:42, Junio C Hamano ha scritto:

Marco Stornelli  writes:


Il 01/09/2012 15:59, Johannes Sixt ha scritto:


Look how you write:

perl -e '... $ENV{'PATCHTMP'} ...'

That is, perl actually sees this script:

... $ENV{PATCHTMP} ...

(no quotes around PATCHTMP). That my be perfectly valid perl, but is not
what you intended.


I don't understand what you mean when you say "is not what you
intended"...


When you wrote this:

 CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'};...

which one of the following did you mean to feed Perl?

  (1) open FILE, $ENV{'PATCHTMP'};
  (2) open FILE, $ENV{PATCHTMP};

The patch text makes it look as if you wanted to do (1), but what is
fed to perl is (2), as Johannes points out.

Saying:

 CCS=`perl -e 'local $/=undef; open FILE, $ENV{PATCHTMP};...

would have been more natural if you really meant to do (2), don't
you think?  So what you wrote is at least misleading.

But I think I agree with Johannes's rewrite of the loop, so this may
be a moot point.



I tried the Johannes's script, but it seems it doesn't work well with 
the pattern of format-patch (To: ,\n   ,\n). 
The multilines are not well managed. I can change my script to double 
quotas (I think perl and regexp are much more powerful rather than the 
while loop though it can be less readable), if it's not ok, I let other 
git shell expert to adjust the script. I hope this thread it will be 
useful for others.


Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-03 Thread Marco Stornelli
2012/9/2 Junio C Hamano :
> Marco Stornelli  writes:
>
>> Il 01/09/2012 15:59, Johannes Sixt ha scritto:
>>
>>> Look how you write:
>>>
>>>perl -e '... $ENV{'PATCHTMP'} ...'
>>>
>>> That is, perl actually sees this script:
>>>
>>>... $ENV{PATCHTMP} ...
>>>
>>> (no quotes around PATCHTMP). That my be perfectly valid perl, but is not
>>> what you intended.
>>
>> I don't understand what you mean when you say "is not what you
>> intended"...
>
> When you wrote this:
>
> CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'};...
>
> which one of the following did you mean to feed Perl?
>
>  (1) open FILE, $ENV{'PATCHTMP'};
>  (2) open FILE, $ENV{PATCHTMP};
>
> The patch text makes it look as if you wanted to do (1), but what is
> fed to perl is (2), as Johannes points out.
>
> Saying:
>
> CCS=`perl -e 'local $/=undef; open FILE, $ENV{PATCHTMP};...
>
> would have been more natural if you really meant to do (2), don't
> you think?  So what you wrote is at least misleading.
>
> But I think I agree with Johannes's rewrite of the loop, so this may
> be a moot point.

Ok, I'll try to rewrite it as Johannes has suggested.

Regards,

Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-01 Thread Marco Stornelli

Il 01/09/2012 15:59, Johannes Sixt ha scritto:

Am 01.09.2012 09:43, schrieb Marco Stornelli:

Il 31/08/2012 23:35, Johannes Sixt ha scritto:

Am 31.08.2012 16:09, schrieb Marco Stornelli:

+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'};
$text=;
+close FILE; $addr = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $addr
=~ s/\n//g;
+print $addr;'`


The quoting is broken in this line (sq within sq does not work).


I don't understand what you mean, I'm using this script and it works
perfectly.


Look how you write:

   perl -e '... $ENV{'PATCHTMP'} ...'

That is, perl actually sees this script:

   ... $ENV{PATCHTMP} ...

(no quotes around PATCHTMP). That my be perfectly valid perl, but is not
what you intended.

-- Hannes




I don't understand what you mean when you say "is not what you intended" 
because perl and this script does *exactly* what I want and (with the 
test I've done) it works. Have you got a test case where it doesn't work 
at all? However, since I'm not a perl guru, if someone says that double 
quotes are needed, ok the result is however the same.


Git guys, let me know if a version 6 of the patch is needed, no problem 
to submit another version.


Regards,

Marco
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5] Thunderbird: fix appp.sh format problems

2012-09-01 Thread Marco Stornelli
The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not English;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded from Cc used in the commit message
instead of using the Cc field filled by format-patch in the email
header.

Added comments for point 1), added parsing of To: for point 2) and
added parsing of Cc: in the email header for point 3), removing the
Cc: parsing from commit message.

Signed-off-by: Marco Stornelli 
---

v5: fixed comments by Junio C Hamano
v4: create a tmp file to allow correct perl parsing
v3: parse only To: and Cc: in the email header, fix some comments
v2: changed the commit message to reflect better the script implementation
v1: first draft

 contrib/thunderbird-patch-inline/appp.sh |   25 +
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..5e4e892 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
 CONFFILE=~/.appprc
 
 SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,31 @@ fi
 cd - > /dev/null
 
 SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
 BODY=`sed -e "1,/${SEP}/d" $1`
 CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
 DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
+PATCHTMP="${PATCH}.tmp"
+
+sed '/^$/q' "${PATCH}" > "${PATCHTMP}"
+
+export PATCHTMP
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
 
-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+rm -f ${PATCHTMP}
 
+# Change Subject: before next line according to Thunderbird language
+# for example to translate in Italian:
+# SUBJECT=`echo $SUBJECT | sed -e 's/^Subject:/Oggetto:/g'`
 echo "$SUBJECT" > $1
+# Change To: according to Thunderbird language
+echo "To: $TO" >> $1
 echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
 echo "$SEP" >> $1
 
 echo "$CMT_MSG" >> $1
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-01 Thread Marco Stornelli

Il 31/08/2012 19:08, Junio C Hamano ha scritto:

Marco Stornelli  writes:


The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not english;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded from Cc used in the commit message
instead of using the Cc field filled by format-patch in the email
header.

Added comments for point 1), added parsing of To: for point 2) and
added parsing of Cc: in the email header for point 3), removing the
Cc: parsing from commit message.

Signed-off-by: Marco Stornelli 
---


Thanks. [+cc Lukas].

A few new issues your patch introduced:

  - MAILHEADER is only set once to read from sed, and then used once
to be echoed to another file.  Just send sed output to the file.

  - The "s/Subject/Oggetto/g" bit in my previous review.

(find the fix-up at the end).



v4: create a tmp file to allow correct perl parsing
v3: parse only To: and Cc: in the email header, fix some comments
v2: changed the commit message to reflect better the script implementation
v1: first draft

  contrib/thunderbird-patch-inline/appp.sh |   26 ++
  1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..0daeb29 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@

  # ExternalEditor can be downloaded at 
http://globs.org/articles.php?lng=en&pg=2

+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
  CONFFILE=~/.appprc

  SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,32 @@ fi
  cd - > /dev/null

  SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
  BODY=`sed -e "1,/${SEP}/d" $1`
  CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
  DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
+MAILHEADER=`sed '/^$/q' "${PATCH}"`
+PATCHTMP="${PATCH}.tmp"
+
+echo $MAILHEADER > $PATCHTMP
+
+export PATCHTMP
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`

-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+rm -rf $PATCHTMP

+# Change Subject: before next line according to Thunderbird language
+# for example:
+# SUBJECT=`echo $SUBJECT | sed -e 's/Subject/Oggetto/g'`
  echo "$SUBJECT" > $1
+# Change To: according to Thunderbird language
+echo "To: $TO" >> $1
  echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
  echo "$SEP" >> $1

  echo "$CMT_MSG" >> $1



I also wonder what would happen if To: and Cc: in the input were
split into continuation lines, but that was already present in the


Do you mean To: ,.\nCc: ,.?


version before your patch, so the attached fix-up won't touch that
part, but you may want to think about it.


Actually I'm trying the script in two ways: with --to and --cc of git 
format patch => multilines, and with a little script (see below) to have 
automatically Cc: from other script, in this case get_maintainer.pl from 
Linux kernel source tree, and it works perfectly. In the last case Cc: 
mail addresses are on the same line.

Maybe we can add even this script, but maybe it's too kernel-specific.


#!/bin/bash

if [[ ! $# -eq 1 ]]
then
echo "Usage: command , where PATH contains kernel and 
patches"

exit
fi

PATCHPATH=${1%/}
for i in `ls $PATCHPATH/*.patch`
do

CCN=`grep "Cc:" $i | wc -l`
if [ $CCN -ge 1 ]
then
echo "Cc: list already present, skip..."
else

CCLIST=`$PATCHPATH/scripts/get_maintainer.pl 
--norolestats --no-git --separator , $i`


sed -n -e "/^$/,999 ! p" $i > $i.new
echo "Cc: $CCLIST" >> $i.new
sed -n -e "/^$/,999 p" $i >> $i.new
mv $i.new $i
fi
done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] Thunderbird: fix appp.sh format problems

2012-09-01 Thread Marco Stornelli

Il 31/08/2012 23:35, Johannes Sixt ha scritto:

Am 31.08.2012 16:09, schrieb Marco Stornelli:

+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`


The quoting is broken in this line (sq within sq does not work).


I don't understand what you mean, I'm using this script and it works 
perfectly.




Am I correct that you intend to treat continuation lines with this
non-trivial perl script? All this processing gets tedious and
unreadable. Let me suggest this pattern instead:


The perl script is used to have To: and Cc: email addresses in single 
line, without using \n. I tried with sed, but it's a little bit 
difficult (at least for me) because sed usually works on a single line, 
it's tricky with multilines.




# translate to Thunderbird language
LANG_TO="To:"
LANG_SUBJ="Subject:"
LANG_CC="Cc:"

LF= # terminates the _previous_ line
while read -r line
do
case $line in
'To: '*)
printf "${LF}%s" "$LANG_TO ${line#To: }"
;;
'Cc: '*) ...similar...
'Subject: '*) ...similar...
' '*)   # continuation line
printf "%s" "$line"
;;
'')
print "${LF}\n"
cat
;;
esac
LF='\n'
done <"$PATCH" >"$1"

Instead of printing right away, you can also accumulate the data in
variables and print them right before the 'cat'. I would do that only if
a particular order of To:, Cc:, and Subject: is required in the output.

(I don't know how the "do not delete this line" line fits in the
picture, but I'm sure you can figure it out.)

-- Hannes



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] Thunderbird: fix appp.sh format problems

2012-08-31 Thread Marco Stornelli
The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not english;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded from Cc used in the commit message
instead of using the Cc field filled by format-patch in the email
header.

Added comments for point 1), added parsing of To: for point 2) and
added parsing of Cc: in the email header for point 3), removing the
Cc: parsing from commit message.

Signed-off-by: Marco Stornelli 
---

v4: create a tmp file to allow correct perl parsing
v3: parse only To: and Cc: in the email header, fix some comments
v2: changed the commit message to reflect better the script implementation
v1: first draft

 contrib/thunderbird-patch-inline/appp.sh |   26 ++
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..0daeb29 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
 CONFFILE=~/.appprc
 
 SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,32 @@ fi
 cd - > /dev/null
 
 SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
 BODY=`sed -e "1,/${SEP}/d" $1`
 CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
 DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
+MAILHEADER=`sed '/^$/q' "${PATCH}"`
+PATCHTMP="${PATCH}.tmp"
+
+echo $MAILHEADER > $PATCHTMP
+
+export PATCHTMP
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{'PATCHTMP'}; $text=;
+close FILE; $addr = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $addr =~ s/\n//g;
+print $addr;'`
 
-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+rm -rf $PATCHTMP
 
+# Change Subject: before next line according to Thunderbird language
+# for example:
+# SUBJECT=`echo $SUBJECT | sed -e 's/Subject/Oggetto/g'`
 echo "$SUBJECT" > $1
+# Change To: according to Thunderbird language
+echo "To: $TO" >> $1
 echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
 echo "$SEP" >> $1
 
 echo "$CMT_MSG" >> $1
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] Thunderbird: fix appp.sh format problems

2012-08-31 Thread Marco Stornelli
The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not English;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded from Cc used in the commit message
instead of using the Cc field filled by format-patch in the email
header.

Added comments for point 1), added parsing of To: for point 2) and
added parsing of Cc: in the email header for point 3), removing the
Cc: parsing from commit message.

Signed-off-by: Marco Stornelli 
---

v3: parse only To: and Cc: in the email header, fix some comments
v2: changed the commit message to reflect better the script implementation
v1: first draft

 contrib/thunderbird-patch-inline/appp.sh |   21 +
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..9325366 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
 CONFFILE=~/.appprc
 
 SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,27 @@ fi
 cd - > /dev/null
 
 SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
 BODY=`sed -e "1,/${SEP}/d" $1`
 CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
 DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
+MAILHEADER=`sed '/^$/q' "${PATCH}"`
+
+export MAILHEADER
+CCS=`perl -e 'local $/=undef; $text=$ENV{'MAILHEADER'};
+$cc = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $cc =~ s/\n//g;
+print $cc;'`
 
-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+TO=`perl -e 'local $/=undef; $text=$ENV{'MAILHEADER'};
+$to = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $to =~ s/\n//g;
+print $to;'`
 
+# Change Subject: before next line according to Thunderbird language
+# for example to translate in Italian:
+# SUBJECT=`echo $SUBJECT | sed -e 's/Subject/Oggetto/g'`
 echo "$SUBJECT" > $1
+# Change To: according to Thunderbird language
+echo "To: $TO" >> $1
 echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
 echo "$SEP" >> $1
 
 echo "$CMT_MSG" >> $1
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] Thunderbird: fix appp.sh format problems

2012-08-31 Thread Marco Stornelli

Il 30/08/2012 19:00, Junio C Hamano ha scritto:

Marco Stornelli  writes:


The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not English;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded only from Cc used in the commit message
instead of using even the Cc field filled by format-patch in the email
header.

Added comments for point 1). Fixed point 2) and 3).

Signed-off-by: Marco Stornelli 
---
v2: changed the commit message to reflect better the script implementation


I actually thought what the log message of the previous version
claimed to do was much more sensible.

The language used in the above 3 items describe what you perceive as
a problem, but it is unclear what the desired behaviour that is
different from the current one is.  (2) "... is not evaluated"
implies ", which is a problem, so fix it by evaluating it", but
there is no single obvious fix to (3) "loaded only from Cc in commit
and not Cc from format-patch".  Should it ignore Cc from commit log
message, or should it take Cc from both log message and e-mail
header?  I personally think it should the former, but it is not
clear which you think is the right thing to do (or perhaps you have
a third answer) if you only say "Fixed point 3".


Ok, I can change the commit. Actually with the new implementation Cc: is 
evaluated in both cases.




  contrib/thunderbird-patch-inline/appp.sh |   18 ++
  1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..e6e1b85 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@

  # ExternalEditor can be downloaded at 
http://globs.org/articles.php?lng=en&pg=2

+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
  CONFFILE=~/.appprc

  SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,24 @@ fi
  cd - > /dev/null

  SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
  BODY=`sed -e "1,/${SEP}/d" $1`
  CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
  DIFF=`sed -e '1,/^---$/d' "${PATCH}"`

-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+export PATCH
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCH'}; $text=;
+close FILE; $cc = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $cc =~ s/\n//g;
+print $cc;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{'PATCH'}; $text=;
+close FILE; $to = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $to =~ s/\n//g;
+print $to;'`

+# Change  before next line according to Thunderbird language
  echo "$SUBJECT" > $1


"before next line"???  I do not think you meant to rename the
variable $SUBJECT to $.


In my case I add a line before in this way:


SUBJECT=`echo $SUBJECT | sed 's/Subject/Oggetto/g'`
echo "$SUBJECT" > $1





+# Change  according to Thunderbird language


# Change "To: " according to...


Ok.



would be less confusing, as the line has to "to" on it when viewed
case insensitively.


+echo "To: $TO" >> $1



  echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
  echo "$SEP" >> $1

  echo "$CMT_MSG" >> $1




--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] Thunderbird: fix appp.sh format problems

2012-08-30 Thread Marco Stornelli
The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not English;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded only from Cc used in the commit message
instead of using even the Cc field filled by format-patch in the email
header.

Added comments for point 1). Fixed point 2) and 3).

Signed-off-by: Marco Stornelli 
---
v2: changed the commit message to reflect better the script implementation

 contrib/thunderbird-patch-inline/appp.sh |   18 ++
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..e6e1b85 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
 CONFFILE=~/.appprc
 
 SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,24 @@ fi
 cd - > /dev/null
 
 SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
 BODY=`sed -e "1,/${SEP}/d" $1`
 CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
 DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
 
-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+export PATCH
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCH'}; $text=;
+close FILE; $cc = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $cc =~ s/\n//g;
+print $cc;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{'PATCH'}; $text=;
+close FILE; $to = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $to =~ s/\n//g;
+print $to;'`
 
+# Change  before next line according to Thunderbird language
 echo "$SUBJECT" > $1
+# Change  according to Thunderbird language
+echo "To: $TO" >> $1
 echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
 echo "$SEP" >> $1
 
 echo "$CMT_MSG" >> $1
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Thunderbird: fix appp.sh format problems

2012-08-30 Thread Marco Stornelli
The current script has got the following problems:

1) It doesn't work if the language used by Thunderbird is not English;
2) The field To: filled by format-patch is not evaluated;
3) The field Cc: is loaded from Cc used in the commit message
instead of using the Cc field filled by format-patch in the email
header. In addition, in the commit message we can find several tags
(acked-by, tested-by, reported-by...), so it'd better to use only the
information provided by format-patch.

Added comments for point 1). Fixed point 2) and 3).

Signed-off-by: Marco Stornelli 
---
 contrib/thunderbird-patch-inline/appp.sh |   18 ++
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/contrib/thunderbird-patch-inline/appp.sh 
b/contrib/thunderbird-patch-inline/appp.sh
index 5eb4a51..e6e1b85 100755
--- a/contrib/thunderbird-patch-inline/appp.sh
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -6,6 +6,9 @@
 
 # ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
 
+# NOTE: You must change some words in this script according to the language
+# used by Mozilla Thunderbird, as , , .
+
 CONFFILE=~/.appprc
 
 SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
@@ -26,17 +29,24 @@ fi
 cd - > /dev/null
 
 SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
-HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
 BODY=`sed -e "1,/${SEP}/d" $1`
 CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
 DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
 
-CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
-   -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+export PATCH
+CCS=`perl -e 'local $/=undef; open FILE, $ENV{'PATCH'}; $text=;
+close FILE; $cc = $1 if $text =~ /Cc: (.*?(,\n .*?)*)\n/s; $cc =~ s/\n//g;
+print $cc;'`
+
+TO=`perl -e 'local $/=undef; open FILE, $ENV{'PATCH'}; $text=;
+close FILE; $to = $1 if $text =~ /To: (.*?(,\n .*?)*)\n/s; $to =~ s/\n//g;
+print $to;'`
 
+# Change  before next line according to Thunderbird language
 echo "$SUBJECT" > $1
+# Change  according to Thunderbird language
+echo "To: $TO" >> $1
 echo "Cc: $CCS" >> $1
-echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
 echo "$SEP" >> $1
 
 echo "$CMT_MSG" >> $1
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html