Merge branch 'db/am-skip-blank-at-the-beginning'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Aug 2011 05:07:57 +0000 (22:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Aug 2011 05:07:57 +0000 (22:07 -0700)
* db/am-skip-blank-at-the-beginning:
am: ignore leading whitespace before patch

1  2 
git-am.sh
diff --combined git-am.sh
index 57150eb7ba204495689304c21be23f3bbf3e2392,c8422dbe6e54fc2e2d2648dbbf39af94f0bd8d70..b2c4b2b853fd2f0f99e08b108efcc9ace7ca1f3e
+++ b/git-am.sh
@@@ -22,7 -22,6 +22,7 @@@ whitespace=     pass it through git-app
  ignore-space-change pass it through git-apply
  ignore-whitespace pass it through git-apply
  directory=      pass it through git-apply
 +exclude=        pass it through git-apply
  C=              pass it through git-apply
  p=              pass it through git-apply
  patch-format=   format the patch(es) are in
@@@ -197,10 -196,15 +197,15 @@@ check_patch_format () 
                return 0
        fi
  
-       # otherwise, check the first few lines of the first patch to try
-       # to detect its format
+       # otherwise, check the first few non-blank lines of the first
+       # patch to try to detect its format
        {
-               read l1
+               # Start from first line containing non-whitespace
+               l1=
+               while test -z "$l1"
+               do
+                       read l1
+               done
                read l2
                read l3
                case "$l1" in
@@@ -367,7 -371,7 +372,7 @@@ d
                ;;
        --resolvemsg)
                shift; resolvemsg=$1 ;;
 -      --whitespace|--directory)
 +      --whitespace|--directory|--exclude)
                git_apply_opt="$git_apply_opt $(sq "$1=$2")"; shift ;;
        -C|-p)
                git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
@@@ -512,8 -516,6 +517,8 @@@ els
        fi
  fi
  
 +git update-index -q --refresh
 +
  case "$resolved" in
  '')
        case "$HAS_HEAD" in