Merge branch 'bc/mailsplit-cr-at-eol'
authorJunio C Hamano <gitster@pobox.com>
Sat, 22 Aug 2009 01:47:44 +0000 (18:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 22 Aug 2009 01:47:44 +0000 (18:47 -0700)
* bc/mailsplit-cr-at-eol:
Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings
builtin-mailsplit.c: remove read_line_with_nul() since it is no longer used
builtin-mailinfo,builtin-mailsplit: use strbufs
strbuf: add new function strbuf_getwholeline()

1  2 
git-am.sh
diff --combined git-am.sh
index f719f6e654fdb7ee92013c824af439b5f0f58f95,985226bfecb8a208fda1f57cec80870c79e289dc..5396be227931ebc2a302cd1aebd86e028733a69c
+++ b/git-am.sh
@@@ -191,27 -191,19 +191,33 @@@ 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
  }
  
  split_patches () {
        case "$patch_format" in
        mbox)
-               git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||
+               case "$rebasing" in
+               '')
+                       keep_cr= ;;
+               ?*)
+                       keep_cr=--keep-cr ;;
+               esac
+               git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > "$dotest/last" ||
                clean_abort
                ;;
        stgit-series)
                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
  }