#!/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