t / t4150-am-subdir.shon commit Merge branch 'maint' (57cf5ca)
   1#!/bin/sh
   2
   3test_description='git am running from a subdirectory'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        echo hello >world &&
   9        git add world &&
  10        test_tick &&
  11        git commit -m initial &&
  12        git tag initial &&
  13        echo goodbye >world &&
  14        git add world &&
  15        test_tick &&
  16        git commit -m second &&
  17        git format-patch --stdout HEAD^ >patchfile &&
  18        : >expect
  19'
  20
  21test_expect_success 'am regularly from stdin' '
  22        git checkout initial &&
  23        git am <patchfile &&
  24        git diff master >actual &&
  25        test_cmp expect actual
  26'
  27
  28test_expect_success 'am regularly from file' '
  29        git checkout initial &&
  30        git am patchfile &&
  31        git diff master >actual &&
  32        test_cmp expect actual
  33'
  34
  35test_expect_success 'am regularly from stdin in subdirectory' '
  36        rm -fr subdir &&
  37        git checkout initial &&
  38        (
  39                mkdir -p subdir &&
  40                cd subdir &&
  41                git am <../patchfile
  42        ) &&
  43        git diff master>actual &&
  44        test_cmp expect actual
  45'
  46
  47test_expect_success 'am regularly from file in subdirectory' '
  48        rm -fr subdir &&
  49        git checkout initial &&
  50        (
  51                mkdir -p subdir &&
  52                cd subdir &&
  53                git am ../patchfile
  54        ) &&
  55        git diff master >actual &&
  56        test_cmp expect actual
  57'
  58
  59test_expect_success 'am regularly from file in subdirectory with full path' '
  60        rm -fr subdir &&
  61        git checkout initial &&
  62        P=$(pwd) &&
  63        (
  64                mkdir -p subdir &&
  65                cd subdir &&
  66                git am "$P/patchfile"
  67        ) &&
  68        git diff master >actual &&
  69        test_cmp expect actual
  70'
  71
  72test_done