t / t4150-am-subdir.shon commit Merge branch 'jc/cherry-pick' (early part) (5d921e2)
   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        diff -u 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        diff -u 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        diff -u 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        diff -u 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        diff -u expect actual
  70'
  71
  72test_done