Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Submitting patches [was: Re: Updated _git completion (not attached)]



Johan Sundström wrote:
> On Fri, Mar 18, 2011 at 14:18, Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:
>> [Etc/zsh-development-guide]
>
> This document doesn't mention it yet, but I assume it's best to submit
> patches in the message body rather than as attachments? (Unless, I suppose,
> they contain binary content.)

I think this is true (simply because it makes commenting patches
easier). But my answer on the matter is certainly not authoritative. I
thought I had seen similar comments on the list before; but I couldn't
find any in a quick search via
<http://www.zsh.org/cgi-bin/mla/wilma/workers>.

>> That being said, the output of "git format-patch" is usable,
>> too. Exchanging git's default "[PATCH]" by "PATCH: " would be extra
>> sugar.
>
> Running perl -pi -e 's/^(Subject: ).(PATCH[^]]*)./$1$2:/' *.patch on
> format-patch files fixes that (it seems command line options to git can't).
> Maybe a useful note for the dev guide?

The archive reacts to anything that starts with "PATCH". You can see the
results on <http://www.zsh.org/mla/patches.shtml>. So, your Perl snippet
would work. Even for numbered patches. The only thing I could think of
this could break is if there's a second line in the file that matches
your regular expression. Here is a zsh function which is using ed(1)
instead of Perl to achieve something similar. This is pretty much what
I've been using in the past.


function gsfix() {
    # zsh-workers prefers PATCH: as its prefix.
    #   fixes [PATCH] to PATCH:
    #     and [PATCH m/n] to PATCH: (m/n)

    if (( ${#argv} == 0 )); then
        printf 'Usage: gsfix <FILE(s)>\n'
        return 1
    fi

    local file
    for file in "$@"; do
        if [[ ! -w "${file}" ]]; then
            printf 'Cannot write to file: %s. Skipping.\n' "${file}"
            continue
        fi
        (
            printf '/^Subject: \[\n'
            printf 's,\[PATCH \([0-9]\+/[0-9]\+\)\],PATCH: (\\1),\n'
            printf 'w\nq\n'
        ) | ed "${file}" > /dev/null 2>&1

        [ "$?" -eq 0 ] && continue

        (
            printf '/^Subject: \[\n'
            printf 's,\[PATCH\],PATCH:,\n'
            printf 'w\nq\n'
        ) | ed "${file}" > /dev/null 2>&1
    done

    return 0
}

I don't know if we should put either into the development guide as a
note, since git isn't zsh's official VCS. And if it were, we could
probably change the patch archive code to handle git's "[PATCH] "
prefix.

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



Messages sorted by: Reverse Date, Date, Thread, Author