git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob fed4929af311b6d7fb55acf5b3050aad5c582c74 9062 bytes (raw)
name: t/t4216-log-bloom.sh 	 # note: path name is non-authoritative(*)

  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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
 
#!/bin/sh

test_description='git log for a path with Bloom filters'
. ./test-lib.sh

GIT_TEST_COMMIT_GRAPH=0
GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0

test_expect_success 'setup test - repo, commits, commit graph, log outputs' '
	git init &&
	mkdir A A/B A/B/C &&
	test_commit c1 A/file1 &&
	test_commit c2 A/B/file2 &&
	test_commit c3 A/B/C/file3 &&
	test_commit c4 A/file1 &&
	test_commit c5 A/B/file2 &&
	test_commit c6 A/B/C/file3 &&
	test_commit c7 A/file1 &&
	test_commit c8 A/B/file2 &&
	test_commit c9 A/B/C/file3 &&
	test_commit c10 file_to_be_deleted &&
	git checkout -b side HEAD~4 &&
	test_commit side-1 file4 &&
	git checkout master &&
	git merge side &&
	test_commit c11 file5 &&
	mv file5 file5_renamed &&
	git add file5_renamed &&
	git commit -m "rename" &&
	rm file_to_be_deleted &&
	git add . &&
	git commit -m "file removed" &&
	git commit-graph write --reachable --changed-paths &&

	test_oid_cache <<-EOF
	oid_version sha1:1
	oid_version sha256:2
	EOF
'
graph_read_expect () {
	NUM_CHUNKS=6
	cat >expect <<- EOF
	header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
	num_commits: $1
	chunks: oid_fanout oid_lookup commit_metadata bloom_indexes bloom_data
	EOF
	test-tool read-graph >actual &&
	test_cmp expect actual
}

test_expect_success 'commit-graph write wrote out the bloom chunks' '
	graph_read_expect 15
'

# Turn off any inherited trace2 settings for this test.
sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT
sane_unset GIT_TRACE2_PERF_BRIEF
sane_unset GIT_TRACE2_CONFIG_PARAMS

setup () {
	rm -f "$TRASH_DIRECTORY/trace.perf" &&
	git -c core.commitGraph=false log --pretty="format:%s" $1 >log_wo_bloom &&
	GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.perf" git -c core.commitGraph=true log --pretty="format:%s" $1 >log_w_bloom
}

test_bloom_filters_used () {
	log_args=$1
	bloom_trace_prefix="statistics:{\"filter_not_present\":${2:-0},\"maybe\""
	setup "$log_args" &&
	grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" &&
	test_cmp log_wo_bloom log_w_bloom &&
    test_path_is_file "$TRASH_DIRECTORY/trace.perf"
}

test_bloom_filters_not_used () {
	log_args=$1
	setup "$log_args" &&
	! grep -q "statistics:{\"filter_not_present\":" "$TRASH_DIRECTORY/trace.perf" &&
	test_cmp log_wo_bloom log_w_bloom
}

for path in A A/B A/B/C A/file1 A/B/file2 A/B/C/file3 file4 file5 file5_renamed file_to_be_deleted
do
	for option in "" \
	      "--all" \
		      "--full-history" \
		      "--full-history --simplify-merges" \
		      "--simplify-merges" \
		      "--simplify-by-decoration" \
		      "--follow" \
		      "--first-parent" \
		      "--topo-order" \
		      "--date-order" \
		      "--author-date-order" \
		      "--ancestry-path side..master"
	do
		test_expect_success "git log option: $option for path: $path" '
			test_bloom_filters_used "$option -- $path" &&
			test_config commitgraph.readChangedPaths false &&
			test_bloom_filters_not_used "$option -- $path"
		'
	done
done

test_expect_success 'git log -- folder works with and without the trailing slash' '
	test_bloom_filters_used "-- A" &&
	test_bloom_filters_used "-- A/"
'

test_expect_success 'git log for path that does not exist. ' '
	test_bloom_filters_used "-- path_does_not_exist"
'

test_expect_success 'git log with --walk-reflogs does not use Bloom filters' '
	test_bloom_filters_not_used "--walk-reflogs -- A"
'

test_expect_success 'git log -- multiple path specs does not use Bloom filters' '
	test_bloom_filters_not_used "-- file4 A/file1"
'

test_expect_success 'git log -- "." pathspec at root does not use Bloom filters' '
	test_bloom_filters_not_used "-- ."
'

test_expect_success 'git log with wildcard that resolves to a single path uses Bloom filters' '
	test_bloom_filters_used "-- *4" &&
	test_bloom_filters_used "-- *renamed"
'

test_expect_success 'git log with wildcard that resolves to a multiple paths does not uses Bloom filters' '
	test_bloom_filters_not_used "-- *" &&
	test_bloom_filters_not_used "-- file*"
'

test_expect_success 'setup - add commit-graph to the chain without Bloom filters' '
	test_commit c14 A/anotherFile2 &&
	test_commit c15 A/B/anotherFile2 &&
	test_commit c16 A/B/C/anotherFile2 &&
	git commit-graph write --reachable --split --no-changed-paths &&
	test_line_count = 2 .git/objects/info/commit-graphs/commit-graph-chain
'

test_expect_success 'use Bloom filters even if the latest graph does not have Bloom filters' '
	# Ensure that the number of empty filters is equal to the number of
	# filters in the latest graph layer to prove that they are loaded (and
	# ignored).
	test_bloom_filters_used "-- A/B" 3
'

test_expect_success 'setup - add commit-graph to the chain with Bloom filters' '
	test_commit c17 A/anotherFile3 &&
	git commit-graph write --reachable --changed-paths --split &&
	test_line_count = 3 .git/objects/info/commit-graphs/commit-graph-chain
'

test_bloom_filters_used_when_some_filters_are_missing () {
	log_args=$1
	bloom_trace_prefix="statistics:{\"filter_not_present\":3,\"maybe\":6,\"definitely_not\":8"
	setup "$log_args" &&
	grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" &&
	test_cmp log_wo_bloom log_w_bloom
}

test_expect_success 'Use Bloom filters if they exist in the latest but not all commit graphs in the chain.' '
	test_bloom_filters_used_when_some_filters_are_missing "-- A/B"
'

test_expect_success 'persist filter settings' '
	test_when_finished rm -rf .git/objects/info/commit-graph* &&
	rm -rf .git/objects/info/commit-graph* &&
	GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
		GIT_TRACE2_EVENT_NESTING=5 \
		GIT_TEST_BLOOM_SETTINGS_NUM_HASHES=9 \
		GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY=15 \
		git commit-graph write --reachable --changed-paths &&
	grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15" trace2.txt &&
	GIT_TRACE2_EVENT="$(pwd)/trace2-auto.txt" \
		GIT_TRACE2_EVENT_NESTING=5 \
		git commit-graph write --reachable --changed-paths &&
	grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15" trace2-auto.txt
'

test_expect_success 'correctly report changes over limit' '
	git init limits &&
	(
		cd limits &&
		mkdir d &&
		mkdir d/e &&

		for i in $(test_seq 1 2)
		do
			printf $i >d/file$i.txt &&
			printf $i >d/e/file$i.txt || return 1
		done &&

		mkdir mode &&
		printf bash >mode/script.sh &&

		mkdir foo &&
		touch foo/bar &&
		touch foo.txt &&

		git add d foo foo.txt mode &&
		git commit -m "files" &&

		# Commit has 7 file and 4 directory adds
		GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=10 \
			GIT_TRACE2_EVENT="$(pwd)/trace" \
			git commit-graph write --reachable --changed-paths &&
		grep "\"max_changed_paths\":10" trace &&
		grep "\"filter_found_large\":1" trace &&

		for path in $(git ls-tree -r --name-only HEAD)
		do
			git -c commitGraph.readChangedPaths=false log \
				-- $path >expect &&
			git log -- $path >actual &&
			test_cmp expect actual || return 1
		done &&

		# Make a variety of path changes
		printf new1 >d/e/file1.txt &&
		printf new2 >d/file2.txt &&
		rm d/e/file2.txt &&
		rm -r foo &&
		printf text >foo &&
		mkdir f &&
		printf new1 >f/file1.txt &&

		# including a mode-only change (counts as modified)
		git update-index --chmod=+x mode/script.sh &&

		git add foo d f &&
		git commit -m "complicated" &&

		# start from scratch and rebuild
		rm -f .git/objects/info/commit-graph &&
		GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=10 \
			GIT_TRACE2_EVENT="$(pwd)/trace-edit" \
			git commit-graph write --reachable --changed-paths &&
		grep "\"max_changed_paths\":10" trace-edit &&
		grep "\"filter_found_large\":2" trace-edit &&

		for path in $(git ls-tree -r --name-only HEAD)
		do
			git -c commitGraph.readChangedPaths=false log \
				-- $path >expect &&
			git log -- $path >actual &&
			test_cmp expect actual || return 1
		done &&

		# start from scratch and rebuild
		rm -f .git/objects/info/commit-graph &&
		GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=11 \
			GIT_TRACE2_EVENT="$(pwd)/trace-update" \
			git commit-graph write --reachable --changed-paths &&
		grep "\"max_changed_paths\":11" trace-update &&
		grep "\"filter_found_large\":0" trace-update &&

		for path in $(git ls-tree -r --name-only HEAD)
		do
			git -c commitGraph.readChangedPaths=false log \
				-- $path >expect &&
			git log -- $path >actual &&
			test_cmp expect actual || return 1
		done
	)
'
test_bloom_filters_computed () {
	commit_graph_args=$1
	bloom_trace_prefix="{\"filter_known_large\":$2,\"filter_found_large\":$3,\"filter_computed\":$4"
	rm -f "$TRASH_DIRECTORY/trace.event" &&
	GIT_TRACE2_EVENT="$TRASH_DIRECTORY/trace.event" git commit-graph write $commit_graph_args &&
	grep "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.event"
}

test_expect_success 'Bloom generation does not recompute too-large filters' '
	(
		cd limits &&

		# start from scratch and rebuild
		rm -f .git/objects/info/commit-graph &&
		GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=10 \
			git commit-graph write --reachable --changed-paths \
			--split=replace &&
		test_commit c1 filter &&

		test_bloom_filters_computed "--reachable --changed-paths --split=replace" \
			2 0 1
	)
'

test_done

debug log:

solving fed4929af3 ...
found fed4929af3 in https://public-inbox.org/git/3063beb58859f997188ae0cca046aaa93eec3d9d.1599172908.git.me@ttaylorr.com/
found e8788749bf in https://public-inbox.org/git/427f129656c0b8112c33e75cd2b49959be42481e.1599172908.git.me@ttaylorr.com/
found 47ddf2641f in https://public-inbox.org/git/9bd699560b5489d64ebc830f0b3cdbba42c373f1.1599664389.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/965489d3617ec03be90d12402fda29fc2b1ead63.1599172908.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/dcc6769ca9fcf3496f266c9131ac355ad422642f.1600279373.git.me@ttaylorr.com/
found fc7693806c in https://public-inbox.org/git/63c4a4901b6d695a29a44d0c734eea04087e71ca.1599664389.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/8aff54d83e26953476da7ca9a1676bd945c00aa2.1599172908.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/29bc0d07c9422d58ae19750390bb08b8c739a03e.1600279373.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/2e79a470319612b293748cdc0c1fe601cf2e20f1.1600397826.git.me@ttaylorr.com/
found cd89c75002 in https://public-inbox.org/git/44df936e51e88e41d5ed9aa02d0bd3ca86696f09.1599664389.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/677b2f1692b3b6dca8695e415fdb11b320b0a432.1600279373.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/d60698d2f8f2888b15729f1ec1fea4a1128f90c4.1599172907.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/6c2a8c9c2f19c6a41aa22f25f3bb54defae4835e.1600397826.git.me@ttaylorr.com/
found 715912ad0f in https://public-inbox.org/git/97d80f109f5c470a8ca3d17ef9d451787b0b609e.1599172907.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/c33976713be2ee8fa42fc13357c49d5b3d8baebf.1599664389.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/db305fe3d698f297f1d3359516f5e5d18627adbe.1600279373.git.me@ttaylorr.com/ ||
	https://public-inbox.org/git/8f8a82224364ba6ca487d99d0e2cafeabe2edc5a.1600397826.git.me@ttaylorr.com/
found 4bb9e9dbe2 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 4bb9e9dbe28bf22d86d7e4ef8629d4f73328d815	t/t4216-log-bloom.sh

applying [1/6] https://public-inbox.org/git/97d80f109f5c470a8ca3d17ef9d451787b0b609e.1599172907.git.me@ttaylorr.com/
diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index 4bb9e9dbe2..715912ad0f 100755

Checking patch t/t4216-log-bloom.sh...
Applied patch t/t4216-log-bloom.sh cleanly.

skipping https://public-inbox.org/git/c33976713be2ee8fa42fc13357c49d5b3d8baebf.1599664389.git.me@ttaylorr.com/ for 715912ad0f
skipping https://public-inbox.org/git/db305fe3d698f297f1d3359516f5e5d18627adbe.1600279373.git.me@ttaylorr.com/ for 715912ad0f
skipping https://public-inbox.org/git/8f8a82224364ba6ca487d99d0e2cafeabe2edc5a.1600397826.git.me@ttaylorr.com/ for 715912ad0f
index at:
100755 715912ad0f89709ab9adf7cb11a9968f6bb10422	t/t4216-log-bloom.sh

applying [2/6] https://public-inbox.org/git/44df936e51e88e41d5ed9aa02d0bd3ca86696f09.1599664389.git.me@ttaylorr.com/
diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index 715912ad0f..cd89c75002 100755

Checking patch t/t4216-log-bloom.sh...
Applied patch t/t4216-log-bloom.sh cleanly.

skipping https://public-inbox.org/git/677b2f1692b3b6dca8695e415fdb11b320b0a432.1600279373.git.me@ttaylorr.com/ for cd89c75002
skipping https://public-inbox.org/git/d60698d2f8f2888b15729f1ec1fea4a1128f90c4.1599172907.git.me@ttaylorr.com/ for cd89c75002
skipping https://public-inbox.org/git/6c2a8c9c2f19c6a41aa22f25f3bb54defae4835e.1600397826.git.me@ttaylorr.com/ for cd89c75002
index at:
100755 cd89c75002377a70e60b1b30c549578b593aa3d9	t/t4216-log-bloom.sh

applying [3/6] https://public-inbox.org/git/63c4a4901b6d695a29a44d0c734eea04087e71ca.1599664389.git.me@ttaylorr.com/
diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index cd89c75002..fc7693806c 100755

Checking patch t/t4216-log-bloom.sh...
Applied patch t/t4216-log-bloom.sh cleanly.

skipping https://public-inbox.org/git/8aff54d83e26953476da7ca9a1676bd945c00aa2.1599172908.git.me@ttaylorr.com/ for fc7693806c
skipping https://public-inbox.org/git/29bc0d07c9422d58ae19750390bb08b8c739a03e.1600279373.git.me@ttaylorr.com/ for fc7693806c
skipping https://public-inbox.org/git/2e79a470319612b293748cdc0c1fe601cf2e20f1.1600397826.git.me@ttaylorr.com/ for fc7693806c
index at:
100755 fc7693806c89bd7eb4738006b0ca8ecc0976a825	t/t4216-log-bloom.sh

applying [4/6] https://public-inbox.org/git/9bd699560b5489d64ebc830f0b3cdbba42c373f1.1599664389.git.me@ttaylorr.com/
diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index fc7693806c..47ddf2641f 100755

Checking patch t/t4216-log-bloom.sh...
Applied patch t/t4216-log-bloom.sh cleanly.

skipping https://public-inbox.org/git/965489d3617ec03be90d12402fda29fc2b1ead63.1599172908.git.me@ttaylorr.com/ for 47ddf2641f
skipping https://public-inbox.org/git/dcc6769ca9fcf3496f266c9131ac355ad422642f.1600279373.git.me@ttaylorr.com/ for 47ddf2641f
index at:
100755 47ddf2641f888bf1fd802478314282bbf0fe94aa	t/t4216-log-bloom.sh

applying [5/6] https://public-inbox.org/git/427f129656c0b8112c33e75cd2b49959be42481e.1599172908.git.me@ttaylorr.com/
diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index 47ddf2641f..e8788749bf 100755


applying [6/6] https://public-inbox.org/git/3063beb58859f997188ae0cca046aaa93eec3d9d.1599172908.git.me@ttaylorr.com/
diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
index e8788749bf..fed4929af3 100755

Checking patch t/t4216-log-bloom.sh...
Applied patch t/t4216-log-bloom.sh cleanly.
Checking patch t/t4216-log-bloom.sh...
Applied patch t/t4216-log-bloom.sh cleanly.

index at:
100755 fed4929af311b6d7fb55acf5b3050aad5c582c74	t/t4216-log-bloom.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public 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).