t / t1004-read-tree-m-u-wf.shon commit Merge branch 'maint' (a695445)
   1#!/bin/sh
   2
   3test_description='read-tree -m -u checks working tree files'
   4
   5. ./test-lib.sh
   6
   7# two-tree test
   8
   9test_expect_success 'two-way setup' '
  10
  11        mkdir subdir &&
  12        echo >file1 file one &&
  13        echo >file2 file two &&
  14        echo >subdir/file1 file one in subdirectory &&
  15        echo >subdir/file2 file two in subdirectory &&
  16        git update-index --add file1 file2 subdir/file1 subdir/file2 &&
  17        git commit -m initial &&
  18
  19        git branch side &&
  20        git tag -f branch-point &&
  21
  22        echo file2 is not tracked on the master anymore &&
  23        rm -f file2 subdir/file2 &&
  24        git update-index --remove file2 subdir/file2 &&
  25        git commit -a -m "master removes file2 and subdir/file2"
  26'
  27
  28test_expect_success 'two-way not clobbering' '
  29
  30        echo >file2 master creates untracked file2 &&
  31        echo >subdir/file2 master creates untracked subdir/file2 &&
  32        if err=`git read-tree -m -u master side 2>&1`
  33        then
  34                echo should have complained
  35                false
  36        else
  37                echo "happy to see $err"
  38        fi
  39'
  40
  41echo file2 >.gitignore
  42
  43test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
  44
  45        if err=`git read-tree -m --exclude-per-directory=.gitignore master side 2>&1`
  46        then
  47                echo should have complained
  48                false
  49        else
  50                echo "happy to see $err"
  51        fi
  52'
  53
  54test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '
  55
  56        if err=`git read-tree -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1`
  57        then
  58                echo should have complained
  59                false
  60        else
  61                echo "happy to see $err"
  62        fi
  63'
  64
  65test_expect_success 'two-way clobbering a ignored file' '
  66
  67        git read-tree -m -u --exclude-per-directory=.gitignore master side
  68'
  69
  70rm -f .gitignore
  71
  72# three-tree test
  73
  74test_expect_success 'three-way not complaining on an untracked path in both' '
  75
  76        rm -f file2 subdir/file2 &&
  77        git checkout side &&
  78        echo >file3 file three &&
  79        echo >subdir/file3 file three &&
  80        git update-index --add file3 subdir/file3 &&
  81        git commit -a -m "side adds file3 and removes file2" &&
  82
  83        git checkout master &&
  84        echo >file2 file two is untracked on the master side &&
  85        echo >subdir/file2 file two is untracked on the master side &&
  86
  87        git read-tree -m -u branch-point master side
  88'
  89
  90test_expect_success 'three-way not clobbering a working tree file' '
  91
  92        git reset --hard &&
  93        rm -f file2 subdir/file2 file3 subdir/file3 &&
  94        git checkout master &&
  95        echo >file3 file three created in master, untracked &&
  96        echo >subdir/file3 file three created in master, untracked &&
  97        if err=`git read-tree -m -u branch-point master side 2>&1`
  98        then
  99                echo should have complained
 100                false
 101        else
 102                echo "happy to see $err"
 103        fi
 104'
 105
 106echo >.gitignore file3
 107
 108test_expect_success 'three-way not complaining on an untracked file' '
 109
 110        git reset --hard &&
 111        rm -f file2 subdir/file2 file3 subdir/file3 &&
 112        git checkout master &&
 113        echo >file3 file three created in master, untracked &&
 114        echo >subdir/file3 file three created in master, untracked &&
 115
 116        git read-tree -m -u --exclude-per-directory=.gitignore branch-point master side
 117'
 118
 119test_done