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

git-am: Add am.keepcr and --no-keep-cr to override it

This patch adds the configuration `am.keepcr` for git-am. It also adds `--no-keep-cr` parameter for git-am to give the possibility to override configuration from command line. 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 e80d4cbefce106506ec217f9ab279bcf0b84a2e9
3 files changed +26 -7
Documentation/config.txt
+7
@@ -555,6 +555,13 @@ it will be treated as a shell command. For example, defining
555 executed from the top-level directory of a repository, which may
556 not necessarily be the current directory.
557
558 +am.keepcr::
559 + If true, git-am will call git-mailsplit for patches in mbox format
560 + with parameter '--keep-cr'. In this case git-mailsplit will
561 + not remove `\r` from lines ending with `\r\n`. Can be overrriden
562 + by giving '--no-keep-cr' from the command line.
563 + See linkgit:git-am[1], linkgit:git-mailsplit[1].
564 +
565 apply.ignorewhitespace::
566 When set to 'change', tells 'git apply' to ignore changes in
567 whitespace, in the same way as the '--ignore-space-change'
Documentation/git-am.txt
+4 -2
@@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox
9 SYNOPSIS
10 --------
11 [verse]
12 -'git am' [--signoff] [--keep] [--keep-cr] [--utf8 | --no-utf8]
12 +'git am' [--signoff] [--keep] [--keep-cr | --no-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>]
@@ -40,9 +40,11 @@ OPTIONS
40 Pass `-k` flag to 'git mailinfo' (see linkgit:git-mailinfo[1]).
41
42 --keep-cr::
43 +--no-keep-cr::
44 With `--keep-cr`, call 'git mailsplit' (see linkgit:git-mailsplit[1])
45 with the same option, to prevent it from stripping CR at the end of
45 - lines.
46 + lines. `am.keepcr` configuration variable can be used to specify the
47 + default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
48
49 -c::
50 --scissors::
git-am.sh
+15 -5
@@ -16,6 +16,7 @@ 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 +no-keep-cr do not pass --keep-cr flag to git-mailsplit independent of am.keepcr
20 c,scissors strip everything before a scissors line
21 whitespace= pass it through git-apply
22 ignore-space-change pass it through git-apply
@@ -218,7 +219,7 @@ check_patch_format () {
219 split_patches () {
220 case "$patch_format" in
221 mbox)
221 - if test -n "$rebasing$keepcr"
222 + if test -n "$rebasing" || test t = "$keepcr"
223 then
224 keep_cr=--keep-cr
225 else
@@ -299,6 +300,11 @@ committer_date_is_author_date=
300 ignore_date=
301 allow_rerere_autoupdate=
302
303 +if test "$(git config --bool --get am.keepcr)" = true
304 +then
305 + keepcr=t
306 +fi
307 +
308 while test $# != 0
309 do
310 case "$1" in
@@ -351,6 +357,8 @@ do
357 GIT_QUIET=t ;;
358 --keep-cr)
359 keepcr=t ;;
360 + --no-keep-cr)
361 + keepcr=f ;;
362 --)
363 shift; break ;;
364 *)
@@ -500,10 +508,12 @@ if test "$(cat "$dotest/keep")" = t
508 then
509 keep=-k
510 fi
503 -if test "$(cat "$dotest/keepcr")" = t
504 -then
505 - keepcr=--keep-cr
506 -fi
511 +case "$(cat "$dotest/keepcr")" in
512 +t)
513 + keepcr=--keep-cr ;;
514 +f)
515 + keepcr=--no-keep-cr ;;
516 +esac
517 case "$(cat "$dotest/scissors")" in
518 t)
519 scissors=--scissors ;;