Discussion:
[BUG] git send-email brakes patches with very long lines
Adam Piatyszek
2008-01-17 10:10:28 UTC
Permalink
Hi Giters,

I suspect that "git send-email" has problems with sending patches with
very long lines.

Please find the attached two emails, which show this problem. The
original file (0001-Add-Dolph-Chebyshev-window.patch) was produced with
"git format-patch" from one of my private Git repositories. The other
file (0001-Add-Dolph-Chebyshev-window-sent.patch) includes the same
patch but sent with "git send-email". The problem is with the last hunk,
which is somehow broken by the "git send-email" tool. The very long
lines are wrapped and some exclamation marks are inserted.

The result of applying such a broken patch in my repository is as follows:

===== >8 =====
***@lespaul ~/git/itpp $ git am 0001-Add-Dolph-Chebyshev-window-sent.patch
Applying Add Dolph Chebyshev window.
fatal: corrupt patch at line 126
Patch failed at 0001.
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip".
===== >8 =====

If I send the same patch with mutt inlined or attached, the patch is not
broken and applies cleanly.

This problem was observed for the following git versions:
- 1.5.3.8
- 1.5.4.rc3.4.g1633

BR,
/Adam


PS. Email and IP addresses have been removed from the attached patches.
--
.:. Adam Piatyszek (ediap) .:.....................................:.
.:. ***@users.sourceforge.net .:................................:.
Adam Piatyszek
2008-01-17 13:26:48 UTC
Permalink
The incorrect line wrapping with an exclamation mark is exactly at 990
column. Is there any limitation of the line size for text/plain messages?
Replying to myself again:

RFC2822 (Internet Message Format) states:

2.1.1. Line Length Limits

There are two limits that this standard places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.

RFC2821 (Simple Mail Transfer Protocol) states:

4.5.3.1 Size limits and minimums
[...]
text line
The maximum total length of a text line including the <CRLF> is 1000
characters (not counting the leading dot duplicated for
transparency). This number may be increased by the use of SMTP
Service Extensions.


Now, the question is. Don't you think that "git send-email" should at
least warn users that they are trying to send emails with patches that
will be broken at the end?

BR,
/Adam
--
.:. Adam Piatyszek (ediap) .:.....................................:.
.:. ***@users.sourceforge.net .:................................:.
Jeff King
2008-01-17 15:32:52 UTC
Permalink
Post by Adam Piatyszek
2.1.1. Line Length Limits
There are two limits that this standard places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.
[...]
Now, the question is. Don't you think that "git send-email" should at
least warn users that they are trying to send emails with patches that
will be broken at the end?
It could actually QP-encode the data in that case, I think. git-mailinfo
appears to have code to handle the decoding.

-Peff
Adam Piątyszek
2008-01-18 07:47:38 UTC
Permalink
According to RFC2822 (Internet Message Format), each line of a message
must be no more than 998 characters. This patch adds a check for the
length of each body line of a message and dies if the length exceeds
the limit.

Signed-off-by: Adam Pi=C4=85tyszek <***@users.sourceforge.net>
---
git-send-email.perl | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index e47994a..6d623ea 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -748,6 +748,9 @@ foreach my $t (@files) {
$header_done =3D 1;
}
} else {
+ if (length($_) > 998) {
+ die "(msg) This message contains lines longer than 998 characters,=
\nwhich can not be correctly send as plain text using SMTP.\n";
+ }
$message .=3D $_;
if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
my $c =3D $2;
--=20
1.5.4.rc3.4.g1633
Johannes Sixt
2008-01-18 08:12:32 UTC
Permalink
According to RFC2822 (Internet Message Format), each line of a messag=
e
must be no more than 998 characters. This patch adds a check for the
length of each body line of a message and dies if the length exceeds
the limit.
=20
---
git-send-email.perl | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
=20
diff --git a/git-send-email.perl b/git-send-email.perl
index e47994a..6d623ea 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -748,6 +748,9 @@ foreach my $t (@files) {
$header_done =3D 1;
}
} else {
+ if (length($_) > 998) {
+ die "(msg) This message contains lines longer than 998 character=
s,\nwhich can not be correctly send as plain text using SMTP.\n";
+ }
$message .=3D $_;
if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
my $c =3D $2;
Is it good to die() in this situation? If you are sending a patch serie=
s
and one patch in the middle triggers this condition, then only half of =
the
series is sent. Maybe it would be better to warn here only, collect fil=
e
names of the suspects, send the patch nevertheless, and write a summary=
at
the end?

-- Hannes
Adam Piatyszek
2008-01-18 09:42:05 UTC
Permalink
Hi,
Is it good to die() in this situation? If you are sending a patch series
and one patch in the middle triggers this condition, then only half of the
series is sent. Maybe it would be better to warn here only, collect file
names of the suspects, send the patch nevertheless, and write a summary at
the end?
Unfortunately, my experience in perl programming is very, very limited.
So, I did not prepared the final solution for this problem. ;-) The
patch was intended as a startup of a discussion how to fix this issue.

IMHO it does not make much sense to send such patches nevertheless, if
we are sure that they will be broken after SMTP transfer. Such a
situation is similar to spamming. And sending only the ones that can be
sent is not an option as well.

The proper solution would be to implement conditional encoding of such
patches, e.g. quoted-printable as suggested by Peff, and warn users that
some patches were send as encoded. Also an explicit option
"--transfer-enc" might be added to control such a behaviour manually.

I guess, git send-email might reuse the code from this perl module:
http://search.cpan.org/src/GAAS/MIME-Base64-Perl-1.00/lib/MIME/QuotedPrint/Perl.pm
to implement the encoding routine.

There are although two things to implement:
1) When too long line is detected, the whole message body has to be
encoded with QP.
2) Proper "Content-Transfer-Encoding: quoted-printable" needs to be set
in the headers.

BTW, is "git am" or "git apply" able to decode the QP encoded message
body? I guess yes, since it works with patches attached to emails as well...

Comments?

BR,
/Adam
--
.:. Adam Piatyszek (ediap) .:.....................................:.
.:. ***@users.sourceforge.net .:................................:.
Johannes Sixt
2008-01-18 10:01:56 UTC
Permalink
Post by Adam Piatyszek
Is it good to die() in this situation? If you are sending a patch series
and one patch in the middle triggers this condition, then only half of the
series is sent. Maybe it would be better to warn here only, collect file
names of the suspects, send the patch nevertheless, and write a summary at
the end?
IMHO it does not make much sense to send such patches nevertheless, if
we are sure that they will be broken after SMTP transfer. Such a
situation is similar to spamming. And sending only the ones that can be
sent is not an option as well.
You are right here. My thought was that even though the recipient gets a
broken patch, he would be able to fix it up. This may be acceptable for
peer-to-peer communication, but not for a development style that involves
many recipients.

Then git-format-patch and log-family with --pretty=email -p could warn
about these candidates-to-be-broken patches.

-- Hannes
Junio C Hamano
2008-01-18 10:08:24 UTC
Permalink
Post by Johannes Sixt
You are right here. My thought was that even though the recipient gets a
broken patch, he would be able to fix it up. This may be acceptable for
peer-to-peer communication, but not for a development style that involves
many recipients.
Then git-format-patch and log-family with --pretty=email -p could warn
about these candidates-to-be-broken patches.
I'd rather not, unless it is explicitly asked for by a separate
command line option. Transferring over SMTP is not the only
(nor even primary) use of format-patch output.

On the other hand, git-send-email _is_ all about SMTP transfer.
Perhaps a loop over input files upfront to check the line length
limit, and warn if there are suspiciously long lines even before
sending the first piece of e-mail out, would be a reasonable
approach.
Adam Piatyszek
2008-01-18 10:37:04 UTC
Permalink
Post by Junio C Hamano
Post by Johannes Sixt
Then git-format-patch and log-family with --pretty=email -p could warn
about these candidates-to-be-broken patches.
I'd rather not, unless it is explicitly asked for by a separate
command line option. Transferring over SMTP is not the only
(nor even primary) use of format-patch output.
Agree.
Post by Junio C Hamano
On the other hand, git-send-email _is_ all about SMTP transfer.
Perhaps a loop over input files upfront to check the line length
limit, and warn if there are suspiciously long lines even before
sending the first piece of e-mail out, would be a reasonable
approach.
But what next? Still send the problematic patches not encoded?

In my opinion, it is more reasonable to provide an optional encoding of
such patches. And only throw a warning message that some of the patches
had to be encoded. Then, we would not need an extra loop over all patches.

As git-send-email _is_ all about SMTP transfer, we should be interested
that the stuff we transfer is sent correctly.

/Adam
--
.:. Adam Piatyszek (ediap) .:.....................................:.
.:. ***@users.sourceforge.net .:................................:.
Junio C Hamano
2008-01-18 11:01:10 UTC
Permalink
Post by Adam Piatyszek
But what next? Still send the problematic patches not encoded?
I meant "warn and stop before sending anything". The sender can
fix it up in any way he wants.

You _could_ give an option to send-email to allow it to QP and
wrap without failing (perhaps with warning), but that should be
explicitly asked for, as some people/list do not want MIME. On
such a list, the sender may even have to go back to the tree and
fix the file contents before regenerating the patches.
Jeff King
2008-01-18 14:16:39 UTC
Permalink
Post by Junio C Hamano
On the other hand, git-send-email _is_ all about SMTP transfer.
Perhaps a loop over input files upfront to check the line length
limit, and warn if there are suspiciously long lines even before
sending the first piece of e-mail out, would be a reasonable
approach.
I think that is sensible. Patch series will follow:

1/3: send-email: detect invocation errors earlier

This is a code cleanup in preparation for 2/3, but has
user-friendly side effects.

2/3: send-email: validate patches before sending anything

The actual up front long-lines check.

3/3: send-email: add no-validate option

A knob for users who know something send-email doesn't.

That at least detects the situation and lets the user deal with it (by
fixing the patch, or by sending it as an attachment with another MUA).
Probably there should be a

4/3: send-email: add --encoding parameter

but I am not inclined to code it, especially this late in the release
freeze (though I think the first three are reasonable for v1.5.4, I am
also fine if you want to put them off -- I don't see this as a common
problem).

-Peff
Jeff King
2008-01-18 14:19:36 UTC
Permalink
We never even look at the command line arguments until after
we have prompted the user for some information. So running
"git send-email" without arguments would prompt for "from"
and "to" headers, only to then die with "No patch files
specified." Instead, let's try to do as much error checking
as possible before getting user input.

Signed-off-by: Jeff King <***@peff.net>
---
git-send-email.perl | 55 +++++++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index e47994a..7a86977 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -314,6 +314,33 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {

($sender) = expand_aliases($sender) if defined $sender;

+# Now that all the defaults are set, process the rest of the command line
+# arguments and collect up the files that need to be processed.
+for my $f (@ARGV) {
+ if (-d $f) {
+ opendir(DH,$f)
+ or die "Failed to opendir $f: $!";
+
+ push @files, grep { -f $_ } map { +$f . "/" . $_ }
+ sort readdir(DH);
+
+ } elsif (-f $f) {
+ push @files, $f;
+
+ } else {
+ print STDERR "Skipping $f - not found.\n";
+ }
+}
+
+if (@files) {
+ unless ($quiet) {
+ print $_,"\n" for (@files);
+ }
+} else {
+ print STDERR "\nNo patch files specified!\n\n";
+ usage();
+}
+
my $prompting = 0;
if (!defined $sender) {
$sender = $repoauthor || $repocommitter;
@@ -427,34 +454,6 @@ EOT
@files = ($compose_filename . ".final");
}

-
-# Now that all the defaults are set, process the rest of the command line
-# arguments and collect up the files that need to be processed.
-for my $f (@ARGV) {
- if (-d $f) {
- opendir(DH,$f)
- or die "Failed to opendir $f: $!";
-
- push @files, grep { -f $_ } map { +$f . "/" . $_ }
- sort readdir(DH);
-
- } elsif (-f $f) {
- push @files, $f;
-
- } else {
- print STDERR "Skipping $f - not found.\n";
- }
-}
-
-if (@files) {
- unless ($quiet) {
- print $_,"\n" for (@files);
- }
-} else {
- print STDERR "\nNo patch files specified!\n\n";
- usage();
-}
-
# Variables we set as part of the loop over files
our ($message_id, %mail, $subject, $reply_to, $references, $message);
--
1.5.4.rc3.1128.g1826-dirty
Jeff King
2008-01-18 14:19:48 UTC
Permalink
We try to catch errors early so that we don't end up sending
half of a broken patch series. Right now the only validation
is checking that line-lengths are under the SMTP-mandated
limit of 998.

The validation parsing is very crude (it just checks each
line length without understanding the mailbox format) but
should work fine for this simple check.

Signed-off-by: Jeff King <***@peff.net>
---
git-send-email.perl | 17 +++++++++++++++++
t/t9001-send-email.sh | 20 ++++++++++++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 7a86977..144d7d4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -332,6 +332,11 @@ for my $f (@ARGV) {
}
}

+foreach my $f (@files) {
+ my $error = validate_patch($f);
+ $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+}
+
if (@files) {
unless ($quiet) {
print $_,"\n" for (@files);
@@ -837,3 +842,15 @@ sub unique_email_list(@) {
}
return @emails;
}
+
+sub validate_patch {
+ my $fn = shift;
+ open(my $fh, '<', $fn)
+ or die "unable to open $fn: $!\n";
+ while (my $line = <$fh>) {
+ if (length($line) > 998) {
+ return "patch contains line longer than 998 characters";
+ }
+ }
+ return undef;
+}
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 659f9c7..1c41810 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -78,4 +78,24 @@ test_expect_success 'Show all headers' '
diff -u expected-show-all-headers actual-show-all-headers
'

+z8=zzzzzzzz
+z64=$z8$z8$z8$z8$z8$z8$z8$z8
+z512=$z64$z64$z64$z64$z64$z64$z64$z64
+test_expect_success 'reject long lines' '
+ rm -f commandline &&
+ cp $patches longline.patch &&
+ echo $z512$z512 >>longline.patch &&
+ ! git send-email \
+ --from="Example <***@example.com>" \
+ --to=***@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches longline.patch \
+ 2>errors &&
+ grep longline.patch errors
+'
+
+test_expect_success 'no patch was sent' '
+ ! test -e commandline
+'
+
test_done
--
1.5.4.rc3.1128.g1826-dirty
Johannes Sixt
2008-01-18 15:09:19 UTC
Permalink
Post by Jeff King
+sub validate_patch {
+ my $fn = shift;
+ open(my $fh, '<', $fn)
+ or die "unable to open $fn: $!\n";
+ while (my $line = <$fh>) {
+ if (length($line) > 998) {
+ return "patch contains line longer than 998 characters";
"... contains line_s_ longer than..."

-- Hannes
Jeff King
2008-01-18 19:09:10 UTC
Permalink
Post by Johannes Sixt
Post by Jeff King
+sub validate_patch {
+ my $fn = shift;
+ open(my $fh, '<', $fn)
+ or die "unable to open $fn: $!\n";
+ while (my $line = <$fh>) {
+ if (length($line) > 998) {
+ return "patch contains line longer than 998 characters";
"... contains line_s_ longer than..."
I actually had that and changed it, since we know of only one such line
(since we bail at that point). I think Jay's suggestion of outputting
the line number is even better.

-Peff
Jay Soffian
2008-01-18 17:39:45 UTC
Permalink
+ my $error = validate_patch($f);
+ $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+}
+
unless ($quiet) {
@@ -837,3 +842,15 @@ sub unique_email_list(@) {
}
}
+
+sub validate_patch {
+ my $fn = shift;
+ open(my $fh, '<', $fn)
+ or die "unable to open $fn: $!\n";
+ while (my $line = <$fh>) {
+ if (length($line) > 998) {
+ return "patch contains line longer than 998 characters";
+ }
+ }
+ return undef;
+}
How about offering the line number. e.g.:

return "patch line number $. is longer than 998 characters";
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 659f9c7..1c41810 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -78,4 +78,24 @@ test_expect_success 'Show all headers' '
diff -u expected-show-all-headers actual-show-all-headers
'
+test_expect_success 'no patch was sent' '
Shouldn't that be "no patches were sent" to match the perl output?

j.
Jeff King
2008-01-18 19:12:01 UTC
Permalink
Post by Jay Soffian
+ return "patch contains line longer than 998 characters";
return "patch line number $. is longer than 998 characters";
I think that is sensible (Junio, if you apply pre-1.5.4, can you mark it
up? Otherwise I will put it in the post-1.5.4 resend).
Post by Jay Soffian
+test_expect_success 'no patch was sent' '
Shouldn't that be "no patches were sent" to match the perl output?
It's purely an informational message for the test script output, so it
doesn't matter.

-Peff
Jeff King
2008-01-18 14:20:10 UTC
Permalink
Since we are now sanity-checking the contents of patches and
refusing to send ones with long lines, this knob provides a
way for the user to override the new behavior (if, e.g., he
knows his SMTP path will handle it).

Signed-off-by: Jeff King <***@peff.net>
---
git-send-email.perl | 12 +++++++++---
t/t9001-send-email.sh | 10 ++++++++++
2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 144d7d4..39e0222 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -100,6 +100,8 @@ Options:

--envelope-sender Specify the envelope sender used to send the emails.

+ --no-validate Don't perform any sanity checks on patches.
+
EOT
exit(1);
}
@@ -177,6 +179,7 @@ my ($quiet, $dry_run) = (0, 0);
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
+my ($no_validate);

my %config_bool_settings = (
"thread" => [\$thread, 1],
@@ -222,6 +225,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"dry-run" => \$dry_run,
"envelope-sender=s" => \$envelope_sender,
"thread!" => \$thread,
+ "no-validate" => \$no_validate,
);

unless ($rc) {
@@ -332,9 +336,11 @@ for my $f (@ARGV) {
}
}

-foreach my $f (@files) {
- my $error = validate_patch($f);
- $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+if (!$no_validate) {
+ foreach my $f (@files) {
+ my $error = validate_patch($f);
+ $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+ }
}

if (@files) {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 1c41810..4f6822f 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -98,4 +98,14 @@ test_expect_success 'no patch was sent' '
! test -e commandline
'

+test_expect_success 'allow long lines with --no-validate' '
+ git send-email \
+ --from="Example <***@example.com>" \
+ --to=***@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ --no-validate \
+ $patches longline.patch \
+ 2>errors
+'
+
test_done
--
1.5.4.rc3.1128.g1826-dirty
Junio C Hamano
2008-01-18 20:57:41 UTC
Permalink
Post by Jeff King
Post by Junio C Hamano
On the other hand, git-send-email _is_ all about SMTP transfer.
Perhaps a loop over input files upfront to check the line length
limit, and warn if there are suspiciously long lines even before
sending the first piece of e-mail out, would be a reasonable
approach.
1/3: send-email: detect invocation errors earlier
This is a code cleanup in preparation for 2/3, but has
user-friendly side effects.
2/3: send-email: validate patches before sending anything
The actual up front long-lines check.
I wonder what the performance implication of this approach would
be, though. I am tempted to say that it would be negligible --
scanning text in Perl is fast enough.
Post by Jeff King
3/3: send-email: add no-validate option
A knob for users who know something send-email doesn't.
That at least detects the situation and lets the user deal with it (by
fixing the patch, or by sending it as an attachment with another MUA).
I suspect that taking this "Safe against SMTP line length limit"
topic all the way ("all the way" is post 1.5.4, I am inclined to
agree that this may be a good fix to an existing bug) would
require that git-format-patch --attach to learn to apply QP on
patch text to avoid producing very long lines to root-cause the
issue [*1*].

[Footnote]

*1* It's actually second-to-root-cause it, because the real root
cause is for the source tree to have such an insanely long line.
Jeff King
2008-01-18 21:30:51 UTC
Permalink
Post by Junio C Hamano
Post by Jeff King
2/3: send-email: validate patches before sending anything
The actual up front long-lines check.
I wonder what the performance implication of this approach would
be, though. I am tempted to say that it would be negligible --
scanning text in Perl is fast enough.
We now open and do one conditional per line for each file (in addition
to already going through each file a separate time and doing more
complex processing). Doing that over the entirety of "git log
--pretty=email -p" on git.git takes about 1 second on my machine for
11402 patches. Obviously there's slightly more syscall overhead as you
have to open() each patch, but I think think it is clear that the
parsing overhead is negligible.
Post by Junio C Hamano
I suspect that taking this "Safe against SMTP line length limit"
topic all the way ("all the way" is post 1.5.4, I am inclined to
agree that this may be a good fix to an existing bug) would
require that git-format-patch --attach to learn to apply QP on
patch text to avoid producing very long lines to root-cause the
issue [*1*].
Perhaps. If such things are sufficiently rare, one could simply attach
the patch in their MUA. I think the most important thing is for git to
at least stop and warn the user that it might not be sending something
valid. But implementing N different fixes that haven't even been
requested by users seems like a waste of time.

-Peff
Adam Piatyszek
2008-01-20 22:35:14 UTC
Permalink
Hi,
Post by Junio C Hamano
Post by Jeff King
1/3: send-email: detect invocation errors earlier
This is a code cleanup in preparation for 2/3, but has
user-friendly side effects.
2/3: send-email: validate patches before sending anything
The actual up front long-lines check.
=20
I wonder what the performance implication of this approach would
be, though. I am tempted to say that it would be negligible --
scanning text in Perl is fast enough.
=20
Post by Jeff King
3/3: send-email: add no-validate option
A knob for users who know something send-email doesn't.
That at least detects the situation and lets the user deal with it (=
by
Post by Junio C Hamano
Post by Jeff King
fixing the patch, or by sending it as an attachment with another MUA=
).

Thanks Peff for your patches. I was about to implement your first two,=20
but it would take me much more time to do it in a sane way. ;-)
Post by Junio C Hamano
I suspect that taking this "Safe against SMTP line length limit"
topic all the way ("all the way" is post 1.5.4, I am inclined to
agree that this may be a good fix to an existing bug) would
require that git-format-patch --attach to learn to apply QP on
patch text to avoid producing very long lines to root-cause the
issue [*1*].
I support this idea. "git-format-patch --attach" is a good place to=20
implement such an additional encoding. Of course, git-mailinfo needs to=
=20
be extended with a decoding method as well.
Post by Junio C Hamano
[Footnote]
=20
*1* It's actually second-to-root-cause it, because the real root
cause is for the source tree to have such an insanely long line.
I can not fully agree with this statement. You should have in mind that=
=20
git is by the definition a "stupid content tracker" and should not=20
assume any particular kind of data being processed.
=46or instance, the reported problem with git-send-email was discovered=
=20
when I tried to send a patch with some reference data of an unformatted=
=20
standard output of a test program.

BR,
/Adam

--=20
=2E:. Adam Piatyszek (ediap) .:.....................................:=
=2E
=2E:. ***@users.sourceforge.net .:................................:=
=2E
Jeff King
2008-01-20 22:53:13 UTC
Permalink
Post by Adam Piatyszek
I support this idea. "git-format-patch --attach" is a good place to
implement such an additional encoding. Of course, git-mailinfo needs to
be extended with a decoding method as well.
I think mailinfo already does support qp, but I haven't tested it (see
builtin-mailinfo.c:decode_q_segment).
Post by Adam Piatyszek
Post by Junio C Hamano
*1* It's actually second-to-root-cause it, because the real root
cause is for the source tree to have such an insanely long line.
I can not fully agree with this statement. You should have in mind that
git is by the definition a "stupid content tracker" and should not assume
any particular kind of data being processed.
For instance, the reported problem with git-send-email was discovered
when I tried to send a patch with some reference data of an unformatted
standard output of a test program.
I agree with you. One of the things that makes git so useful is that you
can feed it any content and everything "just works".

That being said, there is often a distinction in git between 'text' that
is reasonable for patches, mailing, etc, and 'binary', which is not.
Both cases are handled by git, but in different ways appropriate to
each. 1000-character lines are awfully long; should they perhaps be
handled as binary files? The upside is that this fits them into a
well-established niche within git. The downside is that the diffs aren't
readable (though who is reading diffs with such long lines?) and I don't
believe the conflict resolution is as simple.

-Peff
Adam Piatyszek
2008-01-21 10:21:35 UTC
Permalink
Post by Jeff King
Post by Adam Piatyszek
I support this idea. "git-format-patch --attach" is a good place to
implement such an additional encoding. Of course, git-mailinfo needs to
be extended with a decoding method as well.
I think mailinfo already does support qp, but I haven't tested it (see
builtin-mailinfo.c:decode_q_segment).
You are right. I've just tested it and it works fine when
"Content-Transfer-Encoding: quoted-printable" is declared in the header
part of the email. So only the git-format-patch needs some extension for
optional QP encoding.

BR,
/Adam
--
.:. Adam Piatyszek (ediap) .:.....................................:.
.:. ***@users.sourceforge.net .:................................:.
Adam Piatyszek
2008-01-17 13:13:28 UTC
Permalink
Post by Adam Piatyszek
Please find the attached two emails, which show this problem. The
original file (0001-Add-Dolph-Chebyshev-window.patch) was produced with
"git format-patch" from one of my private Git repositories. The other
file (0001-Add-Dolph-Chebyshev-window-sent.patch) includes the same
patch but sent with "git send-email". The problem is with the last hunk,
which is somehow broken by the "git send-email" tool. The very long
lines are wrapped and some exclamation marks are inserted.
===== >8 =====
Applying Add Dolph Chebyshev window.
fatal: corrupt patch at line 126
Patch failed at 0001.
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip".
===== >8 =====
If I send the same patch with mutt inlined or attached, the patch is not
broken and applies cleanly.
Sorry for the noise! It seems that it is not a problem of "git send-email".

I have just resent this patch to myself once again, this time using mutt
"bounce" function, and it resulted in the broken patch in exactly the
same way.

The incorrect line wrapping with an exclamation mark is exactly at 990
column. Is there any limitation of the line size for text/plain messages?

BR,
/Adam
--
.:. Adam Piatyszek (ediap) .:.....................................:.
.:. ***@users.sourceforge.net .:................................:.
Loading...