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

Re: Access to CVS



On Fri, Dec 07, 2012 at 12:03:31PM +0100, Frank Terbeck wrote:
> It would be great if we could make "git-am" process the X-Seq: header,
> too. If that would be possible, integrating someone else's patch from
> the mailing list would boil down to this:
>
>   - Save the mail to a file.
>   - git am foo.patch
>   - git push

On Thu, Dec 13, 2012 at 03:57:47PM +0100, Simon Ruderich wrote:
> Sadly git-am doesn't provide any hooks which get the original
> patch message as argument.
>
> [snip]

Turns out this isn't quite true.

Attached is a simple applypatch-msg hook which extracts the X-Seq
from the original patch and prepends it to the commit message (if
the message doesn't already contain a sequence number).

The hook should work fine all Git versions and works fine with
multiple patches (mbox of patches or multiple patch files passed
to git am).

To use it simply drop it in .git/hooks/ and chmod +x it. Please
tell me what you think. If it works fine we should ship it in
Etc/ and developers can just symlink it into .git/hooks/.


Btw. what's missing to complete the Git conversion? Please tell
me if there's anything I can do to help. I'd really like to see
Zsh finally switch to Git.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
#!/bin/sh

# applypatch-msg for Zsh which extracts X-Seq from the patch and prepends it
# to the commit message.


if test ! -f "$1"; then
    exit 0
fi

# Path to ".git/rebase-apply/" directory.
dotest=`dirname "$1"`
# Path to the patch file which will be applied.
this=`cat "$dotest/next"`
patch="$dotest/`printf '%04d' "$this"`"

# Extract sequence number.
sequence=`grep -E '^X-Seq: ' "$patch" | awk '{ print $2 }'`
if test -z "$sequence"; then
    exit 0
fi

# Prepend sequence number to commit message if not already present.
if ! grep -E '^unposted: ' "$1" > /dev/null &&
   ! grep -E '^[0-9][0-9]*: ' "$1" > /dev/null; then
    printf "%s: " "$sequence" > "$1.tmp"
    cat "$1" >> "$1.tmp"
    mv "$1.tmp" "$1"
fi

Attachment: pgpr_ugbdIFXH.pgp
Description: PGP signature



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