threads / patch / 35883

patchgit-contacts: do not fail parsing of good diffs

Subject: [PATCH] git-contacts: do not fail parsing of good diffs

## tl;dr

3 messages between Feb 15, 2014 and Feb 21, 2014. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Lars Gullik Bjønnes· Feb 15, 2014, 17:24 UTC · lore

If a line in a patch starts with "--- " it will be deemed malformed unless it also contains the proper diff header format. This situation can happen with a valid patch if it has a line starting with "-- " and that line is removed.

This patch just removes the check in git-contacts.
Signed-off-by: Lars Gullik Bjønnes <larsbj@gullik.org>
---
 contrib/contacts/git-contacts | 2 --
 1 file changed, 2 deletions(-)
Show changes to contrib/contacts/git-contacts +0 −2
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index 428cc1a..dbe2abf 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -96,8 +96,6 @@ sub scan_patches {
                next unless $id;
                if (m{^--- (?:a/(.+)|/dev/null)$}) {
                        $source = $1;
-               } elsif (/^--- /) {
-                       die "Cannot parse hunk source: $_\n";
                } elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) {
                        my $len = defined($2) ? $2 : 1;
                        push @{$sources->{$source}{$id}}, [$1, $len] if $len;
-- 
1.9.0

-- 
	Lgb
Junio C Hamano· Feb 18, 2014, 23:14 UTC · re: Lars Gullik Bjønnes · lore

Re: [PATCH] git-contacts: do not fail parsing of good diffs

larsbj@gullik.org (Lars Gullik Bjønnes) writes:
Show 9 quoted lines
> If a line in a patch starts with "--- " it will be deemed
> malformed unless it also contains the proper diff header
> format. This situation can happen with a valid patch if
> it has a line starting with "-- " and that line is removed.
>
> This patch just removes the check in git-contacts.
>
> Signed-off-by: Lars Gullik Bjønnes <larsbj@gullik.org>
> ---

If the script wanted to be "more correct", it should be paying attention to the $len it already parses out of the hunk headers to make sure it does not mistake removal of a line that begins with "-- " as the beginning of a patch to a different path, but as the original does not seem to aim to be so careful anyway, this change should be OK, I would say.

The patch was whitespace damaged, by the way. It was easy to hand tweak so there is no need to resend this particular patch, but if you are planning to send more patches, please check your MUA and tell it not to.

Thanks.
Show 18 quoted lines
>  contrib/contacts/git-contacts | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
> index 428cc1a..dbe2abf 100755
> --- a/contrib/contacts/git-contacts
> +++ b/contrib/contacts/git-contacts
> @@ -96,8 +96,6 @@ sub scan_patches {
>                 next unless $id;
>                 if (m{^--- (?:a/(.+)|/dev/null)$}) {
>                         $source = $1;
> -               } elsif (/^--- /) {
> -                       die "Cannot parse hunk source: $_\n";
>                 } elsif (/^@@ -(\d+)(?:,(\d+))?/ && $source) {
>                         my $len = defined($2) ? $2 : 1;
>                         push @{$sources->{$source}{$id}}, [$1, $len] if $len;
> -- 
> 1.9.0
Lars Gullik Bjønnes· Feb 21, 2014, 00:07 UTC · re: Junio C Hamano · lore

Re: [PATCH] git-contacts: do not fail parsing of good diffs

On 19 February 2014 00:14, Junio C Hamano <gitster@pobox.com> wrote: [...]

> The patch was whitespace damaged, by the way.  It was easy to hand
> tweak so there is no need to resend this particular patch, but if
> you are planning to send more patches, please check your MUA and
> tell it not to.

Suits me right for doing cut-n-paste. Emacs/Gnus usually does not do stupid things like that.

Thanks.

← back to recent threads