t / t4253-am-keep-cr-dos.shon commit Merge branch 'sg/clean-nested-repo-with-ignored' (026428c)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Stefan-W. Hahn
   4#
   5
   6test_description='git-am mbox with dos line ending.
   7
   8'
   9. ./test-lib.sh
  10
  11# Three patches which will be added as files with dos line ending.
  12
  13cat >file1 <<\EOF
  14line 1
  15EOF
  16
  17cat >file1a <<\EOF
  18line 1
  19line 4
  20EOF
  21
  22cat >file2 <<\EOF
  23line 1
  24line 2
  25EOF
  26
  27cat >file3 <<\EOF
  28line 1
  29line 2
  30line 3
  31EOF
  32
  33test_expect_success 'setup repository with dos files' '
  34        append_cr <file1 >file &&
  35        git add file &&
  36        git commit -m Initial &&
  37        git tag initial &&
  38        append_cr <file2 >file &&
  39        git commit -a -m Second &&
  40        append_cr <file3 >file &&
  41        git commit -a -m Third
  42'
  43
  44test_expect_success 'am with dos files without --keep-cr' '
  45        git checkout -b dosfiles initial &&
  46        git format-patch -k initial..master &&
  47        test_must_fail git am -k -3 000*.patch &&
  48        git am --abort &&
  49        rm -rf .git/rebase-apply 000*.patch
  50'
  51
  52test_expect_success 'am with dos files with --keep-cr' '
  53        git checkout -b dosfiles-keep-cr initial &&
  54        git format-patch -k --stdout initial..master >output &&
  55        git am --keep-cr -k -3 output &&
  56        git diff --exit-code master
  57'
  58
  59test_expect_success 'am with dos files config am.keepcr' '
  60        git config am.keepcr 1 &&
  61        git checkout -b dosfiles-conf-keepcr initial &&
  62        git format-patch -k --stdout initial..master >output &&
  63        git am -k -3 output &&
  64        git diff --exit-code master
  65'
  66
  67test_expect_success 'am with dos files config am.keepcr overridden by --no-keep-cr' '
  68        git config am.keepcr 1 &&
  69        git checkout -b dosfiles-conf-keepcr-override initial &&
  70        git format-patch -k initial..master &&
  71        test_must_fail git am -k -3 --no-keep-cr 000*.patch &&
  72        git am --abort &&
  73        rm -rf .git/rebase-apply 000*.patch
  74'
  75
  76test_expect_success 'am with dos files with --keep-cr continue' '
  77        git checkout -b dosfiles-keep-cr-continue initial &&
  78        git format-patch -k initial..master &&
  79        append_cr <file1a >file &&
  80        git commit -m "different patch" file &&
  81        test_must_fail git am --keep-cr -k -3 000*.patch &&
  82        append_cr <file2 >file &&
  83        git add file &&
  84        git am -3 --resolved &&
  85        git diff --exit-code master
  86'
  87
  88test_expect_success 'am with unix files config am.keepcr overridden by --no-keep-cr' '
  89        git config am.keepcr 1 &&
  90        git checkout -b unixfiles-conf-keepcr-override initial &&
  91        cp -f file1 file &&
  92        git commit -m "line ending to unix" file &&
  93        git format-patch -k initial..master &&
  94        git am -k -3 --no-keep-cr 000*.patch &&
  95        git diff --exit-code -w master
  96'
  97
  98test_done