@matheusbsbs / matheus-bagliano / commits / ad2c928001
Fork 0

git-am: Add command line parameter `--keep-cr` passing it to git-mailsplit

c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF line-endings, 2009-08-04) fixed "git mailsplit" to help people with MUA whose output from save-as command uses CRLF as line terminators by stripping CR at the end of lines. However, when you know you are feeding output from "git format-patch" directly to "git am", and especially when your contents have CR at the end of line, such stripping is undesirable. To help such a use case, teach --keep-cr option to "git am" and pass that to "git mailinfo". Signed-off-by: Stefan-W. Hahn <stefan.hahn@s-hahn.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan-W. Hahn committed Feb 27, 2010 at 15:20 UTC ad2c928001d2d94f2cbf3c75734061eb8fc4383c
2 files changed +21 -8
Documentation/git-am.txt
+6 -1
@@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox
9 SYNOPSIS
10 --------
11 [verse]
12 -'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
12 +'git am' [--signoff] [--keep] [--keep-cr] [--utf8 | --no-utf8]
13 [--3way] [--interactive] [--committer-date-is-author-date]
14 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
15 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
@@ -39,6 +39,11 @@ OPTIONS
39 --keep::
40 Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
41
42 +--keep-cr::
43 + With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
44 + with the same option, to prevent it from stripping CR at the end of
45 + lines.
46 +
47 -c::
48 --scissors::
49 Remove everything in body before a scissors line (see
git-am.sh
+15 -7
@@ -15,6 +15,7 @@ q,quiet be quiet
15 s,signoff add a Signed-off-by line to the commit message
16 u,utf8 recode into utf8 (default)
17 k,keep pass -k flag to git-mailinfo
18 +keep-cr pass --keep-cr flag to git-mailsplit for mbox format
19 c,scissors strip everything before a scissors line
20 whitespace= pass it through git-apply
21 ignore-space-change pass it through git-apply
@@ -217,12 +218,12 @@ check_patch_format () {
218 split_patches () {
219 case "$patch_format" in
220 mbox)
220 - case "$rebasing" in
221 - '')
222 - keep_cr= ;;
223 - ?*)
224 - keep_cr=--keep-cr ;;
225 - esac
221 + if test -n "$rebasing$keepcr"
222 + then
223 + keep_cr=--keep-cr
224 + else
225 + keep_cr=
226 + fi
227 git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > "$dotest/last" ||
228 clean_abort
229 ;;
@@ -291,7 +292,7 @@ split_patches () {
292
293 prec=4
294 dotest="$GIT_DIR/rebase-apply"
294 -sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
295 +sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=
296 resolvemsg= resume= scissors= no_inbody_headers=
297 git_apply_opt=
298 committer_date_is_author_date=
@@ -348,6 +349,8 @@ do
349 allow_rerere_autoupdate="$1" ;;
350 -q|--quiet)
351 GIT_QUIET=t ;;
352 + --keep-cr)
353 + keepcr=t ;;
354 --)
355 shift; break ;;
356 *)
@@ -453,6 +456,7 @@ else
456 echo "$sign" >"$dotest/sign"
457 echo "$utf8" >"$dotest/utf8"
458 echo "$keep" >"$dotest/keep"
459 + echo "$keepcr" >"$dotest/keepcr"
460 echo "$scissors" >"$dotest/scissors"
461 echo "$no_inbody_headers" >"$dotest/no_inbody_headers"
462 echo "$GIT_QUIET" >"$dotest/quiet"
@@ -496,6 +500,10 @@ if test "$(cat "$dotest/keep")" = t
500 then
501 keep=-k
502 fi
503 +if test "$(cat "$dotest/keepcr")" = t
504 +then
505 + keepcr=--keep-cr
506 +fi
507 case "$(cat "$dotest/scissors")" in
508 t)
509 scissors=--scissors ;;