]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2025-checkout-no-overlay.sh
The third batch
[thirdparty/git.git] / t / t2025-checkout-no-overlay.sh
CommitLineData
091e04bc
TG
1#!/bin/sh
2
3test_description='checkout --no-overlay <tree-ish> -- <pathspec>'
4
03267e86 5TEST_PASSES_SANITIZE_LEAK=true
091e04bc
TG
6. ./test-lib.sh
7
8test_expect_success 'setup' '
9 git commit --allow-empty -m "initial"
10'
11
12test_expect_success 'checkout --no-overlay deletes files not in <tree-ish>' '
13 >file &&
14 mkdir dir &&
15 >dir/file1 &&
16 git add file dir/file1 &&
17 git checkout --no-overlay HEAD -- file &&
18 test_path_is_missing file &&
19 test_path_is_file dir/file1
20'
21
22test_expect_success 'checkout --no-overlay removing last file from directory' '
23 git checkout --no-overlay HEAD -- dir/file1 &&
24 test_path_is_missing dir
25'
26
27test_expect_success 'checkout -p --overlay is disallowed' '
28 test_must_fail git checkout -p --overlay HEAD 2>actual &&
6789275d 29 test_grep "fatal: options .-p. and .--overlay. cannot be used together" actual
091e04bc
TG
30'
31
32test_expect_success '--no-overlay --theirs with D/F conflict deletes file' '
33 test_commit file1 file1 &&
34 test_commit file2 file2 &&
35 git rm --cached file1 &&
36 echo 1234 >file1 &&
37 F1=$(git rev-parse HEAD:file1) &&
38 F2=$(git rev-parse HEAD:file2) &&
39 {
40 echo "100644 $F1 1 file1" &&
41 echo "100644 $F2 2 file1"
42 } | git update-index --index-info &&
43 test_path_is_file file1 &&
44 git checkout --theirs --no-overlay -- file1 &&
45 test_path_is_missing file1
46'
47
bfda204a
RS
48test_expect_success 'wildcard pathspec matches file in subdirectory' '
49 git reset --hard &&
50 mkdir subdir &&
51 test_commit file3-1 subdir/file3 &&
52 test_commit file3-2 subdir/file3 &&
53
54 git checkout --no-overlay file3-1 "*file3" &&
55 echo file3-1 >expect &&
56 test_path_is_file subdir/file3 &&
57 test_cmp expect subdir/file3
58'
59
091e04bc 60test_done