Commit cd424ad5518c7cfbba10a764d7bc097377ec3995

Russell Belfer 2014-04-28T16:39:53

Add GIT_STATUS_OPT_UPDATE_INDEX and use trace API This adds an option to refresh the stat cache while generating status. It also rips out the GIT_PERF stuff I had an makes use of the trace API to keep statistics about what happens during diff.

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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83e03d6..884c9bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,6 @@ OPTION( ANDROID				"Build for android NDK"	 				OFF )
 OPTION( USE_ICONV			"Link with and use iconv library" 		OFF )
 OPTION( USE_SSH				"Link with libssh to enable SSH support" ON )
 OPTION( VALGRIND			"Configure build for valgrind"			OFF )
-OPTION( PERF_STATS			"Internally track performance data"		OFF )
 
 IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 	SET( USE_ICONV ON )
@@ -353,10 +352,6 @@ IF (THREADSAFE)
 	ADD_DEFINITIONS(-DGIT_THREADS)
 ENDIF()
 
-IF (PERF_STATS)
-	ADD_DEFINITIONS(-DGIT_PERF)
-ENDIF()
-
 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
 
 # Collect sourcefiles
diff --git a/include/git2/status.h b/include/git2/status.h
index 6af45c7..ee2f332 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -121,6 +121,11 @@ typedef enum {
  * - GIT_STATUS_OPT_NO_REFRESH bypasses the default status behavior of
  *   doing a "soft" index reload (i.e. reloading the index data if the
  *   file on disk has been modified outside libgit2).
+ * - GIT_STATUS_OPT_UPDATE_INDEX tells libgit2 to refresh the stat cache
+ *   in the index for files that are unchanged but have out of date stat
+ *   information in the index.  It will result in less work being done on
+ *   subsequent calls to get status.  This is mutually exclusive with the
+ *   NO_REFRESH option.
  *
  * Calling `git_status_foreach()` is like calling the extended version
  * with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED,
@@ -141,6 +146,7 @@ typedef enum {
 	GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY  = (1u << 10),
 	GIT_STATUS_OPT_RENAMES_FROM_REWRITES    = (1u << 11),
 	GIT_STATUS_OPT_NO_REFRESH               = (1u << 12),
+	GIT_STATUS_OPT_UPDATE_INDEX             = (1u << 13),
 } git_status_opt_t;
 
 #define GIT_STATUS_OPT_DEFAULTS \
diff --git a/src/diff.c b/src/diff.c
index caed8bf..8b7433c 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -14,6 +14,7 @@
 #include "index.h"
 #include "odb.h"
 #include "submodule.h"
+#include "trace.h"
 
 #define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0)
 #define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0)
@@ -554,8 +555,7 @@ int git_diff__oid_for_entry(
 	if (!entry.mode) {
 		struct stat st;
 
-		GIT_PERF_INC(diff->stat_calls);
-
+		git_trace(GIT_TRACE_TRACE, "stat=1");
 		if (p_stat(full_path.ptr, &st) < 0) {
 			error = git_path_set_error(errno, entry.path, "stat");
 			git_buf_free(&full_path);
@@ -570,8 +570,7 @@ int git_diff__oid_for_entry(
 	if (S_ISGITLINK(entry.mode)) {
 		git_submodule *sm;
 
-		GIT_PERF_INC(diff->submodule_lookups);
-
+		git_trace(GIT_TRACE_TRACE, "submodule_lookup=1");
 		if (!git_submodule_lookup(&sm, diff->repo, entry.path)) {
 			const git_oid *sm_oid = git_submodule_wd_id(sm);
 			if (sm_oid)
@@ -584,7 +583,7 @@ int git_diff__oid_for_entry(
 			giterr_clear();
 		}
 	} else if (S_ISLNK(entry.mode)) {
-		GIT_PERF_INC(diff->oid_calculations);
+		git_trace(GIT_TRACE_TRACE, "oid_calculation=1");
 		error = git_odb__hashlink(out, full_path.ptr);
 	} else if (!git__is_sizet(entry.file_size)) {
 		giterr_set(GITERR_OS, "File size overflow (for 32-bits) on '%s'",
@@ -597,7 +596,7 @@ int git_diff__oid_for_entry(
 		if (fd < 0)
 			error = fd;
 		else {
-			GIT_PERF_INC(diff->oid_calculations);
+			git_trace(GIT_TRACE_TRACE, "oid_calculation=1");
 			error = git_odb__hashfd_filtered(
 				out, fd, (size_t)entry.file_size, GIT_OBJ_BLOB, fl);
 			p_close(fd);
@@ -656,7 +655,7 @@ static int maybe_modified_submodule(
 		ign == GIT_SUBMODULE_IGNORE_ALL)
 		return 0;
 
-	GIT_PERF_INC(diff->submodule_lookups);
+	git_trace(GIT_TRACE_TRACE, "submodule_lookup=1");
 
 	if ((error = git_submodule_lookup(
 			&sub, diff->repo, info->nitem->path)) < 0) {
@@ -966,7 +965,7 @@ static int handle_unmatched_new_item(
 		delta_type = GIT_DELTA_ADDED;
 
 	else if (nitem->mode == GIT_FILEMODE_COMMIT) {
-		GIT_PERF_INC(diff->submodule_lookups);
+		git_trace(GIT_TRACE_TRACE, "submodule_lookup=1");
 
 		/* ignore things that are not actual submodules */
 		if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) {
@@ -1120,11 +1119,6 @@ int git_diff__from_iterators(
 			error = 0;
 	}
 
-	GIT_PERF_ADD(diff->stat_calls, old_iter->stat_calls);
-	GIT_PERF_ADD(diff->stat_calls, new_iter->stat_calls);
-	GIT_PERF_ADD(diff->submodule_lookups, old_iter->submodule_lookups);
-	GIT_PERF_ADD(diff->submodule_lookups, new_iter->submodule_lookups);
-
 cleanup:
 	if (!error)
 		*diff_ptr = diff;
diff --git a/src/diff.h b/src/diff.h
index b2b7dba..2e7ce0b 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -62,11 +62,6 @@ struct git_diff {
 	git_iterator_type_t old_src;
 	git_iterator_type_t new_src;
 	uint32_t diffcaps;
-#ifdef GIT_PERF
-	size_t stat_calls;
-	size_t oid_calculations;
-	size_t submodule_lookups;
-#endif
 
 	int (*strcomp)(const char *, const char *);
 	int (*strncomp)(const char *, const char *, size_t);
diff --git a/src/iterator.c b/src/iterator.c
index 03058b9..bebdeba 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -11,6 +11,7 @@
 #include "ignore.h"
 #include "buffer.h"
 #include "submodule.h"
+#include "trace.h"
 #include <ctype.h>
 
 #define ITERATOR_SET_CB(P,NAME_LC) do { \
@@ -1017,7 +1018,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi)
 		return GIT_ENOTFOUND;
 	}
 
-	GIT_PERF_ADD(fi->base.stat_calls, ff->entries.length);
+	git_trace(GIT_TRACE_TRACE, "stat=%ld", (long)ff->entries.length);
 
 	fs_iterator__seek_frame_start(fi, ff);
 
@@ -1309,7 +1310,7 @@ static int workdir_iterator__enter_dir(fs_iterator *fi)
 		if (!S_ISDIR(entry->st.st_mode) || !strcmp(GIT_DIR, entry->path))
 			continue;
 
-		GIT_PERF_INC(fi->base.submodule_lookups);
+		git_trace(GIT_TRACE_TRACE, "submodule_lookup=1");
 		if (git_submodule__is_submodule(fi->base.repo, entry->path)) {
 			entry->st.st_mode = GIT_FILEMODE_COMMIT;
 			entry->path_len--;
diff --git a/src/iterator.h b/src/iterator.h
index 2968b8c..ba9c1e4 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -53,10 +53,6 @@ struct git_iterator {
 	char *end;
 	int (*prefixcomp)(const char *str, const char *prefix);
 	unsigned int flags;
-#ifdef GIT_PERF
-	size_t stat_calls;
-	size_t submodule_lookups;
-#endif
 };
 
 extern int git_iterator_for_nothing(
diff --git a/src/status.c b/src/status.c
index e1f8e06..e418cf7 100644
--- a/src/status.c
+++ b/src/status.c
@@ -225,6 +225,28 @@ static git_status_list *git_status_list_alloc(git_index *index)
 	return status;
 }
 
+static int status_validate_options(const git_status_options *opts)
+{
+	if (!opts)
+		return 0;
+
+	GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options");
+
+	if (opts->show > GIT_STATUS_SHOW_WORKDIR_ONLY) {
+		giterr_set(GITERR_INVALID, "Unknown status 'show' option");
+		return -1;
+	}
+
+	if ((opts->flags & GIT_STATUS_OPT_NO_REFRESH) != 0 &&
+		(opts->flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0) {
+		giterr_set(GITERR_INVALID, "Updating index from status "
+			"is not allowed when index refresh is disabled");
+		return -1;
+	}
+
+	return 0;
+}
+
 int git_status_list_new(
 	git_status_list **out,
 	git_repository *repo,
@@ -240,11 +262,10 @@ int git_status_list_new(
 	int error = 0;
 	unsigned int flags = opts ? opts->flags : GIT_STATUS_OPT_DEFAULTS;
 
-	assert(show <= GIT_STATUS_SHOW_WORKDIR_ONLY);
-
 	*out = NULL;
 
-	GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options");
+	if (status_validate_options(opts) < 0)
+		return -1;
 
 	if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 ||
 		(error = git_repository_index(&index, repo)) < 0)
@@ -287,6 +308,8 @@ int git_status_list_new(
 		diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_IGNORED_DIRS;
 	if ((flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0)
 		diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES;
+	if ((flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0)
+		diffopt.flags = diffopt.flags | GIT_DIFF_UPDATE_INDEX;
 
 	if ((flags & GIT_STATUS_OPT_RENAMES_FROM_REWRITES) != 0)
 		findopt.flags = findopt.flags |
diff --git a/src/util.h b/src/util.h
index be7a16e..6fb2dc0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -436,12 +436,4 @@ GIT_INLINE(double) git__timer(void)
 
 #endif
 
-#ifdef GIT_PERF
-#	define GIT_PERF_INC(counter) (counter)++
-#	define GIT_PERF_ADD(counter,val) (counter) += (val)
-#else
-#	define GIT_PERF_INC(counter) 0
-#	define GIT_PERF_ADD(counter,val) 0
-#endif
-
 #endif /* INCLUDE_util_h__ */
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 9e4608e..a225ebc 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -1,21 +1,43 @@
 #include "clar_libgit2.h"
 #include "diff_helpers.h"
 #include "repository.h"
-
-#ifdef GIT_PERF
-/* access to diff usage statistics */
-#	include "diff.h"
-#endif
+#include <git2/trace.h>
 
 static git_repository *g_repo = NULL;
 
+static struct {
+	size_t stat_calls;
+	size_t oid_calcs;
+	size_t submodule_lookups;
+} g_diff_perf;
+
+static void add_stats(git_trace_level_t level, const char *msg)
+{
+	const char *assign = strchr(msg, '=');
+
+	GIT_UNUSED(level);
+
+	if (!assign)
+		return;
+
+	if (!strncmp("stat", msg, (assign - msg)))
+		g_diff_perf.stat_calls += atoi(assign + 1);
+	else if (!strncmp("submodule_lookup", msg, (assign - msg)))
+		g_diff_perf.submodule_lookups += atoi(assign + 1);
+	else if (!strncmp("oid_calculation", msg, (assign - msg)))
+		g_diff_perf.oid_calcs += atoi(assign + 1);
+}
+
 void test_diff_workdir__initialize(void)
 {
+	memset(&g_diff_perf, 0, sizeof(g_diff_perf));
+	cl_git_pass(git_trace_set(GIT_TRACE_TRACE, add_stats));
 }
 
 void test_diff_workdir__cleanup(void)
 {
 	cl_git_sandbox_cleanup();
+	cl_git_pass(git_trace_set(0, NULL));
 }
 
 void test_diff_workdir__to_index(void)
@@ -64,11 +86,11 @@ void test_diff_workdir__to_index(void)
 		cl_assert_equal_i(4, exp.line_adds);
 		cl_assert_equal_i(5, exp.line_dels);
 
-#ifdef GIT_PERF
+#ifdef GIT_TRACE
 		cl_assert_equal_sz(
-			13 /* in root */ + 3 /* in subdir */, diff->stat_calls);
-		cl_assert_equal_sz(5, diff->oid_calculations);
-		cl_assert_equal_sz(1, diff->submodule_lookups);
+			13 /* in root */ + 3 /* in subdir */, g_diff_perf.stat_calls);
+		cl_assert_equal_sz(5, g_diff_perf.oid_calcs);
+		cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
 #endif
 	}
 
@@ -1525,6 +1547,8 @@ static void basic_diff_status(git_diff **out, const git_diff_options *opts)
 {
 	diff_expects exp;
 
+	memset(&g_diff_perf, 0, sizeof(g_diff_perf));
+
 	cl_git_pass(git_diff_index_to_workdir(out, g_repo, NULL, opts));
 
 	memset(&exp, 0, sizeof(exp));
@@ -1558,10 +1582,10 @@ void test_diff_workdir__can_update_index(void)
 	opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
 
 	basic_diff_status(&diff, &opts);
-#ifdef GIT_PERF
-	cl_assert_equal_sz(diff->stat_calls, 13 + 3);
-	cl_assert_equal_sz(diff->oid_calculations, 5);
-	cl_assert_equal_sz(diff->submodule_lookups, 1);
+#ifdef GIT_TRACE
+	cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
+	cl_assert_equal_sz(5, g_diff_perf.oid_calcs);
+	cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
 #endif
 
 	git_diff_free(diff);
@@ -1570,10 +1594,10 @@ void test_diff_workdir__can_update_index(void)
 	opts.flags |= GIT_DIFF_UPDATE_INDEX;
 
 	basic_diff_status(&diff, &opts);
-#ifdef GIT_PERF
-	cl_assert_equal_sz(diff->stat_calls, 13 + 3);
-	cl_assert_equal_sz(diff->oid_calculations, 5);
-	cl_assert_equal_sz(diff->submodule_lookups, 1);
+#ifdef GIT_TRACE
+	cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
+	cl_assert_equal_sz(5, g_diff_perf.oid_calcs);
+	cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
 #endif
 
 	git_diff_free(diff);
@@ -1581,10 +1605,10 @@ void test_diff_workdir__can_update_index(void)
 	/* now if we do it again, we should see fewer OID calculations */
 
 	basic_diff_status(&diff, &opts);
-#ifdef GIT_PERF
-	cl_assert_equal_sz(diff->stat_calls, 13 + 3);
-	cl_assert_equal_sz(diff->oid_calculations, 0); /* Yay */
-	cl_assert_equal_sz(diff->submodule_lookups, 1);
+#ifdef GIT_TRACE
+	cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
+	cl_assert_equal_sz(0, g_diff_perf.oid_calcs); /* Yay */
+	cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
 #endif
 
 	git_diff_free(diff);
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index f51c618..0b94fb1 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -5,6 +5,36 @@
 #include "posix.h"
 #include "util.h"
 #include "path.h"
+#include <git2/trace.h>
+
+static struct {
+	size_t stat_calls;
+	size_t oid_calcs;
+	size_t submodule_lookups;
+} g_diff_perf;
+
+static void add_stats(git_trace_level_t level, const char *msg)
+{
+	const char *assign = strchr(msg, '=');
+
+	GIT_UNUSED(level);
+
+	if (!assign)
+		return;
+
+	if (!strncmp("stat", msg, (assign - msg)))
+		g_diff_perf.stat_calls += atoi(assign + 1);
+	else if (!strncmp("submodule_lookup", msg, (assign - msg)))
+		g_diff_perf.submodule_lookups += atoi(assign + 1);
+	else if (!strncmp("oid_calculation", msg, (assign - msg)))
+		g_diff_perf.oid_calcs += atoi(assign + 1);
+}
+
+void test_status_worktree__initialize(void)
+{
+	memset(&g_diff_perf, 0, sizeof(g_diff_perf));
+	cl_git_pass(git_trace_set(GIT_TRACE_TRACE, add_stats));
+}
 
 /**
  * Cleanup
@@ -15,6 +45,7 @@
 void test_status_worktree__cleanup(void)
 {
 	cl_git_sandbox_cleanup();
+	cl_git_pass(git_trace_set(0, NULL));
 }
 
 /**
@@ -40,11 +71,15 @@ void test_status_worktree__whole_repository(void)
 	cl_assert_equal_i(0, counts.wrong_sorted_path);
 }
 
-void assert_show(const int entry_counts, const char *entry_paths[],
-				 const unsigned int entry_statuses[], git_status_show_t show)
+void assert_show(
+	const int entry_counts,
+	const char *entry_paths[],
+	const unsigned int entry_statuses[],
+	git_repository *repo,
+	git_status_show_t show,
+	unsigned int extra_flags)
 {
 	status_entry_counts counts;
-	git_repository *repo = cl_git_sandbox_init("status");
 	git_status_options opts = GIT_STATUS_OPTIONS_INIT;
 
 	memset(&counts, 0x0, sizeof(status_entry_counts));
@@ -52,7 +87,7 @@ void assert_show(const int entry_counts, const char *entry_paths[],
 	counts.expected_paths = entry_paths;
 	counts.expected_statuses = entry_statuses;
 
-	opts.flags = GIT_STATUS_OPT_DEFAULTS;
+	opts.flags = GIT_STATUS_OPT_DEFAULTS | extra_flags;
 	opts.show = show;
 
 	cl_git_pass(
@@ -67,19 +102,19 @@ void assert_show(const int entry_counts, const char *entry_paths[],
 void test_status_worktree__show_index_and_workdir(void)
 {
 	assert_show(entry_count0, entry_paths0, entry_statuses0,
-		GIT_STATUS_SHOW_INDEX_AND_WORKDIR);
+		cl_git_sandbox_init("status"), GIT_STATUS_SHOW_INDEX_AND_WORKDIR, 0);
 }
 
 void test_status_worktree__show_index_only(void)
 {
 	assert_show(entry_count5, entry_paths5, entry_statuses5,
-		GIT_STATUS_SHOW_INDEX_ONLY);
+		cl_git_sandbox_init("status"), GIT_STATUS_SHOW_INDEX_ONLY, 0);
 }
 
 void test_status_worktree__show_workdir_only(void)
 {
 	assert_show(entry_count6, entry_paths6, entry_statuses6,
-		GIT_STATUS_SHOW_WORKDIR_ONLY);
+		cl_git_sandbox_init("status"), GIT_STATUS_SHOW_WORKDIR_ONLY, 0);
 }
 
 /* this test is equivalent to t18-status.c:statuscb1 */
@@ -877,3 +912,45 @@ void test_status_worktree__long_filenames(void)
 	cl_assert_equal_i(0, counts.wrong_sorted_path);
 }
 
+/* The update stat cache tests mostly just mirror other tests and try
+ * to make sure that updating the stat cache doesn't change the results
+ * while reducing the amount of work that needs to be done
+ */
+
+void test_status_worktree__update_stat_cache_0(void)
+{
+	git_repository *repo = cl_git_sandbox_init("status");
+
+	assert_show(entry_count0, entry_paths0, entry_statuses0,
+		repo, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, 0);
+
+#ifdef GIT_TRACE
+	cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
+	cl_assert_equal_sz(5, g_diff_perf.oid_calcs);
+	cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
+
+	memset(&g_diff_perf, 0, sizeof(g_diff_perf));
+#endif
+
+	assert_show(entry_count0, entry_paths0, entry_statuses0,
+		repo, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, GIT_STATUS_OPT_UPDATE_INDEX);
+
+#ifdef GIT_TRACE
+	cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
+	cl_assert_equal_sz(5, g_diff_perf.oid_calcs);
+	cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
+
+	memset(&g_diff_perf, 0, sizeof(g_diff_perf));
+#endif
+
+	assert_show(entry_count0, entry_paths0, entry_statuses0,
+		repo, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, 0);
+
+#ifdef GIT_TRACE
+	cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
+	cl_assert_equal_sz(0, g_diff_perf.oid_calcs);
+	cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
+
+	memset(&g_diff_perf, 0, sizeof(g_diff_perf));
+#endif
+}