t / t7609-merge-co-error-msgs.shon commit Merge branch 'maint' (bc38219)
   1#!/bin/sh
   2
   3test_description='unpack-trees error messages'
   4
   5. ./test-lib.sh
   6
   7
   8test_expect_success 'setup' '
   9        echo one >one &&
  10        git add one &&
  11        git commit -a -m First &&
  12
  13        git checkout -b branch &&
  14        echo two >two &&
  15        echo three >three &&
  16        echo four >four &&
  17        echo five >five &&
  18        git add two three four five &&
  19        git commit -m Second &&
  20
  21        git checkout master &&
  22        echo other >two &&
  23        echo other >three &&
  24        echo other >four &&
  25        echo other >five
  26'
  27
  28cat >expect <<\EOF
  29error: The following untracked working tree files would be overwritten by merge:
  30        two
  31        three
  32        four
  33        five
  34Please move or remove them before you can merge.
  35EOF
  36
  37test_expect_success 'untracked files overwritten by merge' '
  38        test_must_fail git merge branch 2>out &&
  39        test_cmp out expect
  40'
  41
  42cat >expect <<\EOF
  43error: Your local changes to the following files would be overwritten by merge:
  44        two
  45        three
  46        four
  47Please, commit your changes or stash them before you can merge.
  48error: The following untracked working tree files would be overwritten by merge:
  49        five
  50Please move or remove them before you can merge.
  51EOF
  52
  53test_expect_success 'untracked files or local changes ovewritten by merge' '
  54        git add two &&
  55        git add three &&
  56        git add four &&
  57        test_must_fail git merge branch 2>out &&
  58        test_cmp out expect
  59'
  60
  61cat >expect <<\EOF
  62error: Your local changes to the following files would be overwritten by checkout:
  63        rep/two
  64        rep/one
  65Please, commit your changes or stash them before you can switch branches.
  66EOF
  67
  68test_expect_success 'cannot switch branches because of local changes' '
  69        git add five &&
  70        mkdir rep &&
  71        echo one >rep/one &&
  72        echo two >rep/two &&
  73        git add rep/one rep/two &&
  74        git commit -m Fourth &&
  75        git checkout master &&
  76        echo uno >rep/one &&
  77        echo dos >rep/two &&
  78        test_must_fail git checkout branch 2>out &&
  79        test_cmp out expect
  80'
  81
  82cat >expect <<\EOF
  83error: Your local changes to the following files would be overwritten by checkout:
  84        rep/two
  85        rep/one
  86Please, commit your changes or stash them before you can switch branches.
  87EOF
  88
  89test_expect_success 'not uptodate file porcelain checkout error' '
  90        git add rep/one rep/two &&
  91        test_must_fail git checkout branch 2>out &&
  92        test_cmp out expect
  93'
  94
  95cat >expect <<\EOF
  96error: Updating the following directories would lose untracked files in it:
  97        rep2
  98        rep
  99
 100EOF
 101
 102test_expect_success 'not_uptodate_dir porcelain checkout error' '
 103        git init uptodate &&
 104        cd uptodate &&
 105        mkdir rep &&
 106        mkdir rep2 &&
 107        touch rep/foo &&
 108        touch rep2/foo &&
 109        git add rep/foo rep2/foo &&
 110        git commit -m init &&
 111        git checkout -b branch &&
 112        git rm rep -r &&
 113        git rm rep2 -r &&
 114        >rep &&
 115        >rep2 &&
 116        git add rep rep2&&
 117        git commit -m "added test as a file" &&
 118        git checkout master &&
 119        >rep/untracked-file &&
 120        >rep2/untracked-file &&
 121        test_must_fail git checkout branch 2>out &&
 122        test_cmp out ../expect
 123'
 124
 125test_done