t / t3504-cherry-pick-rerere.shon commit git-quiltimport: add --keep-non-patch option (1eadaa3)
   1#!/bin/sh
   2
   3test_description='cherry-pick should rerere for conflicts'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        test_commit foo &&
   9        test_commit foo-master foo &&
  10        test_commit bar-master bar &&
  11
  12        git checkout -b dev foo &&
  13        test_commit foo-dev foo &&
  14        test_commit bar-dev bar &&
  15        git config rerere.enabled true
  16'
  17
  18test_expect_success 'conflicting merge' '
  19        test_must_fail git merge master
  20'
  21
  22test_expect_success 'fixup' '
  23        echo foo-resolved >foo &&
  24        echo bar-resolved >bar &&
  25        git commit -am resolved &&
  26        cp foo foo-expect &&
  27        cp bar bar-expect &&
  28        git reset --hard HEAD^
  29'
  30
  31test_expect_success 'cherry-pick conflict with --rerere-autoupdate' '
  32        test_must_fail git cherry-pick --rerere-autoupdate foo..bar-master &&
  33        test_cmp foo-expect foo &&
  34        git diff-files --quiet &&
  35        test_must_fail git cherry-pick --continue &&
  36        test_cmp bar-expect bar &&
  37        git diff-files --quiet &&
  38        git cherry-pick --continue &&
  39        git reset --hard bar-dev
  40'
  41
  42test_expect_success 'cherry-pick conflict repsects rerere.autoUpdate' '
  43        test_config rerere.autoUpdate true &&
  44        test_must_fail git cherry-pick foo..bar-master &&
  45        test_cmp foo-expect foo &&
  46        git diff-files --quiet &&
  47        test_must_fail git cherry-pick --continue &&
  48        test_cmp bar-expect bar &&
  49        git diff-files --quiet &&
  50        git cherry-pick --continue &&
  51        git reset --hard bar-dev
  52'
  53
  54test_expect_success 'cherry-pick conflict with --no-rerere-autoupdate' '
  55        test_config rerere.autoUpdate true &&
  56        test_must_fail git cherry-pick --no-rerere-autoupdate foo..bar-master &&
  57        test_cmp foo-expect foo &&
  58        test_must_fail git diff-files --quiet &&
  59        git add foo &&
  60        test_must_fail git cherry-pick --continue &&
  61        test_cmp bar-expect bar &&
  62        test_must_fail git diff-files --quiet &&
  63        git add bar &&
  64        git cherry-pick --continue &&
  65        git reset --hard bar-dev
  66'
  67
  68test_expect_success 'cherry-pick --continue rejects --rerere-autoupdate' '
  69        test_must_fail git cherry-pick --rerere-autoupdate foo..bar-master &&
  70        test_cmp foo-expect foo &&
  71        git diff-files --quiet &&
  72        test_must_fail git cherry-pick --continue --rerere-autoupdate >actual 2>&1 &&
  73        echo "fatal: cherry-pick: --rerere-autoupdate cannot be used with --continue" >expect &&
  74        test_i18ncmp expect actual &&
  75        test_must_fail git cherry-pick --continue --no-rerere-autoupdate >actual 2>&1 &&
  76        echo "fatal: cherry-pick: --no-rerere-autoupdate cannot be used with --continue" >expect &&
  77        test_i18ncmp expect actual &&
  78        git cherry-pick --abort
  79'
  80
  81test_expect_success 'cherry-pick --rerere-autoupdate more than once' '
  82        test_must_fail git cherry-pick --rerere-autoupdate --rerere-autoupdate foo..bar-master &&
  83        test_cmp foo-expect foo &&
  84        git diff-files --quiet &&
  85        git cherry-pick --abort &&
  86        test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate foo..bar-master &&
  87        test_cmp foo-expect foo &&
  88        git diff-files --quiet &&
  89        git cherry-pick --abort &&
  90        test_must_fail git cherry-pick --rerere-autoupdate --no-rerere-autoupdate foo..bar-master &&
  91        test_must_fail git diff-files --quiet &&
  92        git cherry-pick --abort
  93'
  94
  95test_expect_success 'cherry-pick conflict without rerere' '
  96        test_config rerere.enabled false &&
  97        test_must_fail git cherry-pick master &&
  98        test_must_fail test_cmp expect foo
  99'
 100
 101test_done