a2c70ad4b8ba9a3435c76437ec88d9a1919c9294
   1#!/bin/sh
   2
   3test_description='Test cherry-pick continuation features
   4
   5  + anotherpick: rewrites foo to d
   6  + picked: rewrites foo to c
   7  + unrelatedpick: rewrites unrelated to reallyunrelated
   8  + base: rewrites foo to b
   9  + initial: writes foo as a, unrelated as unrelated
  10
  11'
  12
  13. ./test-lib.sh
  14
  15pristine_detach () {
  16        rm -rf .git/sequencer &&
  17        git checkout -f "$1^0" &&
  18        git read-tree -u --reset HEAD &&
  19        git clean -d -f -f -q -x
  20}
  21
  22test_expect_success setup '
  23        echo unrelated >unrelated &&
  24        git add unrelated &&
  25        test_commit initial foo a &&
  26        test_commit base foo b &&
  27        test_commit unrelatedpick unrelated reallyunrelated &&
  28        test_commit picked foo c &&
  29        test_commit anotherpick foo d &&
  30        git config advice.detachedhead false
  31
  32'
  33
  34test_expect_success 'cherry-pick persists data on failure' '
  35        pristine_detach initial &&
  36        test_must_fail git cherry-pick base..anotherpick &&
  37        test_path_is_dir .git/sequencer &&
  38        test_path_is_file .git/sequencer/head &&
  39        test_path_is_file .git/sequencer/todo
  40'
  41
  42test_expect_success 'cherry-pick cleans up sequencer state upon success' '
  43        pristine_detach initial &&
  44        git cherry-pick initial..picked &&
  45        test_path_is_missing .git/sequencer
  46'
  47
  48test_done