]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2021-checkout-overwrite.sh
Merge branch 'ob/t9001-indent-fix'
[thirdparty/git.git] / t / t2021-checkout-overwrite.sh
CommitLineData
2fe26b77
JS
1#!/bin/sh
2
3test_description='checkout must not overwrite an untracked objects'
9081a421
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
2fe26b77
JS
6. ./test-lib.sh
7
8test_expect_success 'setup' '
9
10 mkdir -p a/b/c &&
11 >a/b/c/d &&
12 git add -A &&
13 git commit -m base &&
14 git tag start
15'
16
17test_expect_success 'create a commit where dir a/b changed to file' '
18
19 git checkout -b file &&
20 rm -rf a/b &&
21 >a/b &&
22 git add -A &&
23 git commit -m "dir to file"
24'
25
26test_expect_success 'checkout commit with dir must not remove untracked a/b' '
27
28 git rm --cached a/b &&
29 git commit -m "un-track the file" &&
30 test_must_fail git checkout start &&
31 test -f a/b
32'
33
889c6f0e 34test_expect_success 'create a commit where dir a/b changed to symlink' '
2fe26b77
JS
35
36 rm -rf a/b && # cleanup if previous test failed
37 git checkout -f -b symlink start &&
38 rm -rf a/b &&
2fe26b77 39 git add -A &&
889c6f0e 40 test_ln_s_add foo a/b &&
2fe26b77
JS
41 git commit -m "dir to symlink"
42'
43
889c6f0e 44test_expect_success 'checkout commit with dir must not remove untracked a/b' '
2fe26b77
JS
45
46 git rm --cached a/b &&
47 git commit -m "un-track the symlink" &&
889c6f0e
JS
48 test_must_fail git checkout start
49'
50
51test_expect_success SYMLINKS 'the symlink remained' '
52
2fe26b77
JS
53 test -h a/b
54'
55
24a49cf7
EN
56test_expect_success 'cleanup after previous symlink tests' '
57 rm a/b
58'
59
fab78a0c
MT
60test_expect_success SYMLINKS 'checkout -f must not follow symlinks when removing entries' '
61 git checkout -f start &&
62 mkdir dir &&
63 >dir/f &&
64 git add dir/f &&
65 git commit -m "add dir/f" &&
66 mv dir untracked &&
67 ln -s untracked dir &&
68 git checkout -f HEAD~ &&
69 test_path_is_file untracked/f
70'
71
b413a827
EN
72test_expect_success 'checkout --overwrite-ignore should succeed if only ignored files in the way' '
73 git checkout -b df_conflict &&
74 test_commit contents some_dir &&
75 git checkout start &&
76 mkdir some_dir &&
77 echo autogenerated information >some_dir/ignore &&
78 echo ignore >.git/info/exclude &&
79 git checkout --overwrite-ignore df_conflict &&
eab648d2 80 test_path_is_file some_dir
b413a827
EN
81'
82
2fe26b77 83test_done