Code

svn: properly escape arguments for authors-prog
[git.git] / git-am.sh
index d64d9975358a6b9a18596c45b13434463903a344..f719f6e654fdb7ee92013c824af439b5f0f58f95 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -191,6 +191,20 @@ check_patch_format () {
                        esac
                        ;;
                esac
+               if test -z "$patch_format" &&
+                       test -n "$l1" &&
+                       test -n "$l2" &&
+                       test -n "$l3"
+               then
+                       # This begins with three non-empty lines.  Is this a
+                       # piece of e-mail a-la RFC2822?  Grab all the headers,
+                       # discarding the indented remainder of folded lines,
+                       # and see if it looks like that they all begin with the
+                       # header field names...
+                       sed -n -e '/^$/q' -e '/^[       ]/d' -e p "$1" |
+                       egrep -v '^[A-Za-z]+(-[A-Za-z]+)*:' >/dev/null ||
+                       patch_format=mbox
+               fi
        } < "$1" || clean_abort
 }
 
@@ -254,7 +268,11 @@ split_patches () {
                msgnum=
                ;;
        *)
-               clean_abort "Patch format $patch_format is not supported."
+               if test -n "$parse_patch" ; then
+                       clean_abort "Patch format $patch_format is not supported."
+               else
+                       clean_abort "Patch format detection failed."
+               fi
                ;;
        esac
 }