t / t6020-merge-df.shon commit Merge branch 'sp/maint-fd-limit' (674ef90)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Fredrik Kuivinen
   4#
   5
   6test_description='Test merge with directory/file conflicts'
   7. ./test-lib.sh
   8
   9test_expect_success 'prepare repository' '
  10        echo Hello >init &&
  11        git add init &&
  12        git commit -m initial &&
  13
  14        git branch B &&
  15        mkdir dir &&
  16        echo foo >dir/foo &&
  17        git add dir/foo &&
  18        git commit -m "File: dir/foo" &&
  19
  20        git checkout B &&
  21        echo file dir >dir &&
  22        git add dir &&
  23        git commit -m "File: dir"
  24'
  25
  26test_expect_success 'Merge with d/f conflicts' '
  27        test_expect_code 1 git merge "merge msg" B master
  28'
  29
  30test_expect_success 'F/D conflict' '
  31        git reset --hard &&
  32        git checkout master &&
  33        rm .git/index &&
  34
  35        mkdir before &&
  36        echo FILE >before/one &&
  37        echo FILE >after &&
  38        git add . &&
  39        git commit -m first &&
  40
  41        rm -f after &&
  42        git mv before after &&
  43        git commit -m move &&
  44
  45        git checkout -b para HEAD^ &&
  46        echo COMPLETELY ANOTHER FILE >another &&
  47        git add . &&
  48        git commit -m para &&
  49
  50        git merge master
  51'
  52
  53test_expect_success 'setup modify/delete + directory/file conflict' '
  54        git checkout --orphan modify &&
  55        git rm -rf . &&
  56        git clean -fdqx &&
  57
  58        printf "a\nb\nc\nd\ne\nf\ng\nh\n" >letters &&
  59        git add letters &&
  60        git commit -m initial &&
  61
  62        echo i >>letters &&
  63        git add letters &&
  64        git commit -m modified &&
  65
  66        git checkout -b delete HEAD^ &&
  67        git rm letters &&
  68        mkdir letters &&
  69        >letters/file &&
  70        git add letters &&
  71        git commit -m deleted
  72'
  73
  74test_expect_success 'modify/delete + directory/file conflict' '
  75        git checkout delete^0 &&
  76        test_must_fail git merge modify &&
  77
  78        test 3 = $(git ls-files -s | wc -l) &&
  79        test 2 = $(git ls-files -u | wc -l) &&
  80        test 1 = $(git ls-files -o | wc -l) &&
  81
  82        test -f letters/file &&
  83        test -f letters~modify
  84'
  85
  86test_expect_success 'modify/delete + directory/file conflict; other way' '
  87        git reset --hard &&
  88        git clean -f &&
  89        git checkout modify^0 &&
  90        test_must_fail git merge delete &&
  91
  92        test 3 = $(git ls-files -s | wc -l) &&
  93        test 2 = $(git ls-files -u | wc -l) &&
  94        test 1 = $(git ls-files -o | wc -l) &&
  95
  96        test -f letters/file &&
  97        test -f letters~HEAD
  98'
  99
 100test_done