git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
fdfd8b085e3fe31bcd6dc4418ab42fdff456974d blob 4399 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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
 
#!/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 () {
	rm -f sparse_entry &&
	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 'setup' '
	cat >sparse_error_header <<-EOF &&
	The following pathspecs only matched index entries outside the current
	sparse checkout:
	EOF

	cat >sparse_hint <<-EOF &&
	hint: Disable or modify the sparsity rules if you intend to update such entries.
	hint: Disable this message with "git config advice.updateSparsePath false"
	EOF

	echo sparse_entry | cat sparse_error_header - >sparse_entry_error &&
	cat sparse_entry_error sparse_hint >error_and_hint
'

test_expect_success 'git add does not remove sparse entries' '
	setup_sparse_entry &&
	rm sparse_entry &&
	test_must_fail git add sparse_entry 2>stderr &&
	test_i18ncmp error_and_hint stderr &&
	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 2>stderr &&
	test_must_be_empty stderr &&
	test_sparse_entry_unchanged
'

test_expect_success 'git add . does not remove sparse entries' '
	setup_sparse_entry &&
	rm sparse_entry &&
	setup_gitignore &&
	test_must_fail git add . 2>stderr &&

	cat sparse_error_header >expect &&
	echo . >>expect &&
	cat sparse_hint >>expect &&

	test_i18ncmp expect stderr &&
	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 &&
		test_must_fail git add $opt sparse_entry 2>stderr &&
		test_i18ncmp error_and_hint stderr &&
		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 &&
	test_must_fail git add --refresh sparse_entry 2>stderr &&
	test_i18ncmp error_and_hint stderr &&
	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 &&
	test_must_fail git add --chmod=+x sparse_entry 2>stderr &&
	test_i18ncmp error_and_hint stderr &&
	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 &&
	test_must_fail git add --renormalize sparse_entry 2>stderr &&
	test_i18ncmp error_and_hint stderr &&
	test_sparse_entry_unchanged
'

test_expect_success 'git add --dry-run --ignore-missing warn on sparse path' '
	setup_sparse_entry &&
	rm sparse_entry &&
	test_must_fail git add --dry-run --ignore-missing sparse_entry 2>stderr &&
	test_i18ncmp error_and_hint stderr &&
	test_sparse_entry_unchanged
'

test_expect_success 'do not advice about sparse entries when they do not match the pathspec' '
	setup_sparse_entry &&
	test_must_fail git add nonexistent 2>stderr &&
	test_i18ngrep "fatal: pathspec .nonexistent. did not match any files" stderr &&
	test_i18ngrep ! "The following pathspecs only matched index entries" stderr
'

test_expect_success 'do not warn when pathspec matches dense entries' '
	setup_sparse_entry &&
	echo modified >sparse_entry &&
	>dense_entry &&
	git add "*_entry" 2>stderr &&
	test_must_be_empty stderr &&
	test_sparse_entry_unchanged &&
	git ls-files --error-unmatch dense_entry
'

test_expect_success 'add obeys advice.updateSparsePath' '
	setup_sparse_entry &&
	test_must_fail git -c advice.updateSparsePath=false add sparse_entry 2>stderr &&
	test_i18ncmp sparse_entry_error stderr

'

test_done
debug log:

solving fdfd8b085e ...
found fdfd8b085e in https://public-inbox.org/git/24e889ca9b1cb0823d1663a60ce1e0ba9e55f875.1614138107.git.matheus.bernardino@usp.br/
found 6781620297 in https://public-inbox.org/git/0f03adf241f83dcd97b2be53cd622eedd4695116.1614138107.git.matheus.bernardino@usp.br/
found 9bb5dc2389 in https://public-inbox.org/git/72b87870181d8bf72ce7bf86b5fae2e485fef9c0.1614138107.git.matheus.bernardino@usp.br/

applying [1/3] https://public-inbox.org/git/72b87870181d8bf72ce7bf86b5fae2e485fef9c0.1614138107.git.matheus.bernardino@usp.br/
diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh
new file mode 100755
index 0000000000..9bb5dc2389


applying [2/3] https://public-inbox.org/git/0f03adf241f83dcd97b2be53cd622eedd4695116.1614138107.git.matheus.bernardino@usp.br/
diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh
index 9bb5dc2389..6781620297 100755


applying [3/3] https://public-inbox.org/git/24e889ca9b1cb0823d1663a60ce1e0ba9e55f875.1614138107.git.matheus.bernardino@usp.br/
diff --git a/t/t3705-add-sparse-checkout.sh b/t/t3705-add-sparse-checkout.sh
index 6781620297..fdfd8b085e 100755

Checking patch t/t3705-add-sparse-checkout.sh...
Applied patch t/t3705-add-sparse-checkout.sh cleanly.
Checking patch t/t3705-add-sparse-checkout.sh...
Applied patch t/t3705-add-sparse-checkout.sh cleanly.
Checking patch t/t3705-add-sparse-checkout.sh...
Applied patch t/t3705-add-sparse-checkout.sh cleanly.

index at:
100755 fdfd8b085e3fe31bcd6dc4418ab42fdff456974d	t/t3705-add-sparse-checkout.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).