git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
4174620cf45edab40a12f8d140e956dd13ffed62 blob 2462 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
#!/bin/sh

test_description='checkout $tree -- $paths'
. ./test-lib.sh

test_expect_success setup '
	mkdir dir &&
	>dir/main &&
	echo common >dir/common &&
	git add dir/main dir/common &&
	test_tick && git commit -m "main has dir/main" &&
	git checkout -b next &&
	git mv dir/main dir/next0 &&
	echo next >dir/next1 &&
	git add dir &&
	test_tick && git commit -m "next has dir/next but not dir/main"
'

test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' '
	git checkout next &&
	git reset --hard &&
	rm dir/next0 &&
	cat dir/common >expect.common &&
	echo modified >expect.next1 &&
	cat expect.next1 >dir/next1 &&
	echo untracked >expect.next2 &&
	cat expect.next2 >dir/next2 &&

	git checkout main dir &&

	test_cmp expect.common dir/common &&
	test_path_is_file dir/main &&
	git diff --exit-code main dir/main &&

	test_path_is_missing dir/next0 &&
	test_cmp expect.next1 dir/next1 &&
	test_path_is_file dir/next2 &&
	test_must_fail git ls-files --error-unmatch dir/next2 &&
	test_cmp expect.next2 dir/next2
'

test_expect_success 'do not touch unmerged entries matching $path but not in $tree' '
	git checkout next &&
	git reset --hard &&

	cat dir/common >expect.common &&
	EMPTY_SHA1=$(git hash-object -w --stdin </dev/null) &&
	git rm dir/next0 &&
	cat >expect.next0 <<-EOF &&
	100644 $EMPTY_SHA1 1	dir/next0
	100644 $EMPTY_SHA1 2	dir/next0
	EOF
	git update-index --index-info <expect.next0 &&

	git checkout main dir &&

	test_cmp expect.common dir/common &&
	test_path_is_file dir/main &&
	git diff --exit-code main dir/main &&
	git ls-files -s dir/next0 >actual.next0 &&
	test_cmp expect.next0 actual.next0
'

test_expect_success 'do not touch files that are already up-to-date' '
	git reset --hard &&
	echo one >file1 &&
	echo two >file2 &&
	git add file1 file2 &&
	git commit -m base &&
	echo modified >file1 &&
	test-tool chmtime =1000000000 file2 &&
	git update-index -q --refresh &&
	git checkout HEAD -- file1 file2 &&
	echo one >expect &&
	test_cmp expect file1 &&
	echo "1000000000" >expect &&
	test-tool chmtime --get file2 >actual &&
	test_cmp expect actual
'

test_expect_success 'checkout HEAD adds deleted intent-to-add file back to index' '
	echo "nonempty" >nonempty &&
	>empty &&
	git add nonempty empty &&
	git commit -m "create files to be deleted" &&
	git rm --cached nonempty empty &&
	git add -N nonempty empty &&
	git checkout HEAD nonempty empty &&
	git diff --cached --exit-code
'

test_done
debug log:

solving 4174620cf4 ...
found 4174620cf4 in https://public-inbox.org/git/9b368b1ce1c5462b1a6fda6755837806bf4edfa8.1605221039.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/0d4f1275f745f90a1ea007dfc82510f0040ab4a0.1605629548.git.gitgitgadget@gmail.com/
found 6844afafc0 in git.git.git
preparing index
index prepared:
100755 6844afafc0eb926713e73c1042874155d18c08bc	t/t2022-checkout-paths.sh

applying [1/2] https://public-inbox.org/git/9b368b1ce1c5462b1a6fda6755837806bf4edfa8.1605221039.git.gitgitgadget@gmail.com/
diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh
index 6844afafc0..4174620cf4 100755

Checking patch t/t2022-checkout-paths.sh...
Applied patch t/t2022-checkout-paths.sh cleanly.

skipping https://public-inbox.org/git/0d4f1275f745f90a1ea007dfc82510f0040ab4a0.1605629548.git.gitgitgadget@gmail.com/ for 4174620cf4
index at:
100755 4174620cf45edab40a12f8d140e956dd13ffed62	t/t2022-checkout-paths.sh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).