t / t3509-cherry-pick-merge-df.shon commit Merge branch 'cs/perl-config-path-send-email' (1ff5a41)
   1#!/bin/sh
   2
   3test_description='Test cherry-pick with directory/file conflicts'
   4. ./test-lib.sh
   5
   6test_expect_success 'Initialize repository' '
   7        mkdir a &&
   8        >a/f &&
   9        git add a &&
  10        git commit -m a
  11'
  12
  13test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' '
  14        mkdir b &&
  15        ln -s ../a b/a &&
  16        git add b &&
  17        git commit -m b &&
  18
  19        git checkout -b branch &&
  20        rm b/a &&
  21        mv a b/a &&
  22        ln -s b/a a &&
  23        git add . &&
  24        git commit -m swap &&
  25
  26        >f1 &&
  27        git add f1 &&
  28        git commit -m f1
  29'
  30
  31test_expect_success SYMLINKS 'Cherry-pick succeeds with rename across D/F conflicts' '
  32        git reset --hard &&
  33        git checkout master^0 &&
  34        git cherry-pick branch
  35'
  36
  37test_expect_success 'Setup rename with file on one side matching directory name on other' '
  38        git checkout --orphan nick-testcase &&
  39        git rm -rf . &&
  40
  41        >empty &&
  42        git add empty &&
  43        git commit -m "Empty file" &&
  44
  45        git checkout -b simple &&
  46        mv empty file &&
  47        mkdir empty &&
  48        mv file empty &&
  49        git add empty/file &&
  50        git commit -m "Empty file under empty dir" &&
  51
  52        echo content >newfile &&
  53        git add newfile &&
  54        git commit -m "New file"
  55'
  56
  57test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' '
  58        git reset --hard &&
  59        git checkout -q nick-testcase^0 &&
  60        git cherry-pick --strategy=resolve simple
  61'
  62
  63test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' '
  64        git reset --hard &&
  65        git checkout -q nick-testcase^0 &&
  66        git cherry-pick --strategy=recursive simple
  67'
  68
  69test_expect_success 'Setup rename with file on one side matching different dirname on other' '
  70        git reset --hard &&
  71        git checkout --orphan mergeme &&
  72        git rm -rf . &&
  73
  74        mkdir sub &&
  75        mkdir othersub &&
  76        echo content > sub/file &&
  77        echo foo > othersub/whatever &&
  78        git add -A &&
  79        git commit -m "Common commmit" &&
  80
  81        git rm -rf othersub &&
  82        git mv sub/file othersub &&
  83        git commit -m "Commit to merge" &&
  84
  85        git checkout -b newhead mergeme~1 &&
  86        >independent-change &&
  87        git add independent-change &&
  88        git commit -m "Completely unrelated change"
  89'
  90
  91test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (resolve)' '
  92        git reset --hard &&
  93        git checkout -q newhead^0 &&
  94        git cherry-pick --strategy=resolve mergeme
  95'
  96
  97test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (recursive)' '
  98        git reset --hard &&
  99        git checkout -q newhead^0 &&
 100        git cherry-pick --strategy=recursive mergeme
 101'
 102
 103test_done