Re: [PATCHv2 2/4] git-am foreign patch support: autodetect some patch formats
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
Show 41 quoted lines
> + # otherwise, check the first few lines of the first patch to try
> + # to detect its format
> + {
> + read l1
> + read l2
> + read l3
> + case "$l1" in
> + From\ *)
> + patch_format=mbox
> + ;;
> + From:\ *)
> + patch_format=mbox
> + ;;
> + '# This series applies on GIT commit'*)
> + patch_format=stgit-series
> + ;;
> + "# HG changeset patch")
> + patch_format=hg
> + ;;
> + *)
> + # if the second line is empty and the third is
> + # a From, Author or Date entry, this is very
> + # likely an StGIT patch
> + if test "x$l2" = x
> + then
> + case "$l3" in
> + From:\ *)
> + patch_format=stgit
> + ;;
> + Author:\ *)
> + patch_format=stgit
> + ;;
> + Date:\ *)
> + patch_format=stgit
> + ;;
> + *)
> + ;;
> + esac
> + fi
> + ;;
> + esacDon't make the case unnecessary too deep nor redundant.
...
read l3
case "$l1" in
"From "* | "From: "* )
patch_format=mbox
;;
"# This ...")
...
;;
*)
case "$l2,$l3" in
,"From: "* | ,"Author: "* | ,"Date: "*)
patch_format=stgit
;;
esac
;;
esac
Show 6 quoted lines
> + } < "$1"
> }
>
> split_patches () {
> --
> 1.6.3.1.248.gb44be