Code

Fix checkout of large files to network shares on Windows XP
[git.git] / git-am.sh
index 7644474bcabc191ef11ce6b885a62794ec730a9c..1056075545ad3e5e42626d167c91c1deada6186b 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -15,6 +15,8 @@ q,quiet         be quiet
 s,signoff       add a Signed-off-by line to the commit message
 u,utf8          recode into utf8 (default)
 k,keep          pass -k flag to git-mailinfo
+keep-cr         pass --keep-cr flag to git-mailsplit for mbox format
+no-keep-cr      do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
 c,scissors      strip everything before a scissors line
 whitespace=     pass it through git-apply
 ignore-space-change pass it through git-apply
@@ -25,7 +27,8 @@ p=              pass it through git-apply
 patch-format=   format the patch(es) are in
 reject          pass it through git-apply
 resolvemsg=     override error message when patch failure occurs
-r,resolved      to be used after a patch failure
+continue        continue applying patches after resolving a conflict
+r,resolved      synonyms for --continue
 skip            skip the current patch
 abort           restore the original branch and abort the patching operation.
 committer-date-is-author-date    lie about committer date
@@ -205,7 +208,8 @@ check_patch_format () {
                        # 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" |
+                       tr -d '\015' <"$1" |
+                       sed -n -e '/^$/q' -e '/^[       ]/d' -e p |
                        sane_egrep -v '^[!-9;-~]+:' >/dev/null ||
                        patch_format=mbox
                fi
@@ -215,12 +219,12 @@ check_patch_format () {
 split_patches () {
        case "$patch_format" in
        mbox)
-               case "$rebasing" in
-               '')
-                       keep_cr= ;;
-               ?*)
-                       keep_cr=--keep-cr ;;
-               esac
+               if test -n "$rebasing" || test t = "$keepcr"
+               then
+                   keep_cr=--keep-cr
+               else
+                   keep_cr=
+               fi
                git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > "$dotest/last" ||
                clean_abort
                ;;
@@ -289,13 +293,18 @@ split_patches () {
 
 prec=4
 dotest="$GIT_DIR/rebase-apply"
-sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
+sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=
 resolvemsg= resume= scissors= no_inbody_headers=
 git_apply_opt=
 committer_date_is_author_date=
 ignore_date=
 allow_rerere_autoupdate=
 
+if test "$(git config --bool --get am.keepcr)" = true
+then
+    keepcr=t
+fi
+
 while test $# != 0
 do
        case "$1" in
@@ -317,7 +326,7 @@ do
                scissors=t ;;
        --no-scissors)
                scissors=f ;;
-       -r|--resolved)
+       -r|--resolved|--continue)
                resolved=t ;;
        --skip)
                skip=t ;;
@@ -346,6 +355,10 @@ do
                allow_rerere_autoupdate="$1" ;;
        -q|--quiet)
                GIT_QUIET=t ;;
+       --keep-cr)
+               keepcr=t ;;
+       --no-keep-cr)
+               keepcr=f ;;
        --)
                shift; break ;;
        *)
@@ -451,6 +464,7 @@ else
        echo "$sign" >"$dotest/sign"
        echo "$utf8" >"$dotest/utf8"
        echo "$keep" >"$dotest/keep"
+       echo "$keepcr" >"$dotest/keepcr"
        echo "$scissors" >"$dotest/scissors"
        echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
        echo "$GIT_QUIET" >"$dotest/quiet"
@@ -494,6 +508,12 @@ if test "$(cat "$dotest/keep")" = t
 then
        keep=-k
 fi
+case "$(cat "$dotest/keepcr")" in
+t)
+       keepcr=--keep-cr ;;
+f)
+       keepcr=--no-keep-cr ;;
+esac
 case "$(cat "$dotest/scissors")" in
 t)
        scissors=--scissors ;;
@@ -663,10 +683,7 @@ do
                [eE]*) git_editor "$dotest/final-commit"
                       action=again ;;
                [vV]*) action=again
-                      : ${GIT_PAGER=$(git var GIT_PAGER)}
-                      : ${LESS=-FRSX}
-                      export LESS
-                      $GIT_PAGER "$dotest/patch" ;;
+                      git_pager "$dotest/patch" ;;
                *)     action=again ;;
                esac
            done
@@ -787,6 +804,5 @@ if test -s "$dotest"/rewritten; then
     fi
 fi
 
-git gc --auto
-
 rm -fr "$dotest"
+git gc --auto