git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
00b10ac877d31895ccdf3b2ae74137845cdffde7 blob 2453 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
93
94
95
96
 
#!/bin/sh

test_description='git add in sparse checked out working trees'

. ./test-lib.sh

SPARSE_ENTRY_BLOB=""

# Optionally take a printf format string to write to the sparse_entry file
setup_sparse_entry () {
	# 'sparse_entry' might already be in the index with the skip-worktree
	# bit set. Remove it so that the subsequent git add can update it.
	git update-index --force-remove sparse_entry &&
	if test $# -eq 1
	then
		printf "$1" >sparse_entry
	else
		>sparse_entry
	fi &&
	git add sparse_entry &&
	git update-index --skip-worktree sparse_entry &&
	SPARSE_ENTRY_BLOB=$(git rev-parse :sparse_entry)
}

test_sparse_entry_unchanged () {
	echo "100644 $SPARSE_ENTRY_BLOB 0	sparse_entry" >expected &&
	git ls-files --stage sparse_entry >actual &&
	test_cmp expected actual
}

setup_gitignore () {
	test_when_finished rm -f .gitignore &&
	cat >.gitignore <<-EOF
	*
	!/sparse_entry
	EOF
}

test_expect_success 'git add does not remove sparse entries' '
	setup_sparse_entry &&
	rm sparse_entry &&
	git add sparse_entry &&
	test_sparse_entry_unchanged
'

test_expect_success 'git add -A does not remove sparse entries' '
	setup_sparse_entry &&
	rm sparse_entry &&
	setup_gitignore &&
	git add -A &&
	test_sparse_entry_unchanged
'

test_expect_success 'git add . does not remove sparse entries' '
	setup_sparse_entry &&
	rm sparse_entry &&
	setup_gitignore &&
	git add . &&
	test_sparse_entry_unchanged
'

for opt in "" -f -u --ignore-removal --dry-run
do
	test_expect_success "git add${opt:+ $opt} does not update sparse entries" '
		setup_sparse_entry &&
		echo modified >sparse_entry &&
		git add $opt sparse_entry &&
		test_sparse_entry_unchanged
	'
done

test_expect_success 'git add --refresh does not update sparse entries' '
	setup_sparse_entry &&
	git ls-files --debug sparse_entry | grep mtime >before &&
	test-tool chmtime -60 sparse_entry &&
	git add --refresh sparse_entry &&
	git ls-files --debug sparse_entry | grep mtime >after &&
	test_cmp before after
'

test_expect_success 'git add --chmod does not update sparse entries' '
	setup_sparse_entry &&
	git add --chmod=+x sparse_entry &&
	test_sparse_entry_unchanged &&
	! test -x sparse_entry
'

test_expect_success 'git add --renormalize does not update sparse entries' '
	test_config core.autocrlf false &&
	setup_sparse_entry "LINEONE\r\nLINETWO\r\n" &&
	echo "sparse_entry text=auto" >.gitattributes &&
	git add --renormalize sparse_entry &&
	test_sparse_entry_unchanged
'

test_done
debug log:

solving 00b10ac877 ...
found 00b10ac877 in git.git.git

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).