Re: [PATCH v3] Re: git-am: fix maildir support regression: accept email file as patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nicolas Sebrecht <nicolas.s.dev@xxxxxx> writes:

> I don't see the reason to have the option -v. It's only related to
> what's printed to output and doesn't change the exit status which
> tell us if an expression has matched.
>
> This gives:
>
>    grep -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null &&
>    patch_format=mbox

That grep says "if you see a single line that matches the pattern, even if
all the other lines are garbage, report it as a match".

See "something like this" patch in my other message. It filters the entire
header to make sure there is no line that does not match (that is what -v
is about), and make it report success when there is even a signle line
that does not.

    $ (echo yes; echo no) | grep -v -e yes ; echo $?
    no
    0
    $ (echo yes; echo yes) | grep -v -e yes ; echo $?
    1

That is why I wrote the "how about this" patch with "||" like this:

    grep -v -E -e '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
    patch_format=mbox

If everything is header, grep says "nothing matches", and patch_format
is set to mbox.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]