Skip to content

Commit a7aca15

Browse files
jayesh0104gitster
authored andcommitted
read-cache: use istate->repo for trace2 logging
trace2 calls in read-cache.c use the global 'the_repository', even though the relevant index_state provides an explicit repository pointer via 'istate->repo'. Using the global repository can result in incorrect trace2 output when multiple repository instances are in use, as events may be attributed to the wrong repository. Use 'istate->repo' instead to ensure correct repository attribution. Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5361983 commit a7aca15

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

read-cache.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,13 +2309,9 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23092309
}
23102310
munmap((void *)mmap, mmap_size);
23112311

2312-
/*
2313-
* TODO trace2: replace "the_repository" with the actual repo instance
2314-
* that is associated with the given "istate".
2315-
*/
2316-
trace2_data_intmax("index", the_repository, "read/version",
2312+
trace2_data_intmax("index", istate->repo, "read/version",
23172313
istate->version);
2318-
trace2_data_intmax("index", the_repository, "read/cache_nr",
2314+
trace2_data_intmax("index", istate->repo, "read/cache_nr",
23192315
istate->cache_nr);
23202316

23212317
/*
@@ -2360,16 +2356,12 @@ int read_index_from(struct index_state *istate, const char *path,
23602356
if (istate->initialized)
23612357
return istate->cache_nr;
23622358

2363-
/*
2364-
* TODO trace2: replace "the_repository" with the actual repo instance
2365-
* that is associated with the given "istate".
2366-
*/
2367-
trace2_region_enter_printf("index", "do_read_index", the_repository,
2359+
trace2_region_enter_printf("index", "do_read_index", istate->repo,
23682360
"%s", path);
23692361
trace_performance_enter();
23702362
ret = do_read_index(istate, path, 0);
23712363
trace_performance_leave("read cache %s", path);
2372-
trace2_region_leave_printf("index", "do_read_index", the_repository,
2364+
trace2_region_leave_printf("index", "do_read_index", istate->repo,
23732365
"%s", path);
23742366

23752367
split_index = istate->split_index;
@@ -3096,13 +3088,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30963088
istate->timestamp.nsec = ST_MTIME_NSEC(st);
30973089
trace_performance_since(start, "write index, changed mask = %x", istate->cache_changed);
30983090

3099-
/*
3100-
* TODO trace2: replace "the_repository" with the actual repo instance
3101-
* that is associated with the given "istate".
3102-
*/
3103-
trace2_data_intmax("index", the_repository, "write/version",
3091+
trace2_data_intmax("index", istate->repo, "write/version",
31043092
istate->version);
3105-
trace2_data_intmax("index", the_repository, "write/cache_nr",
3093+
trace2_data_intmax("index", istate->repo, "write/cache_nr",
31063094
istate->cache_nr);
31073095

31083096
ret = 0;
@@ -3144,14 +3132,10 @@ static int do_write_locked_index(struct index_state *istate,
31443132
return ret;
31453133
}
31463134

3147-
/*
3148-
* TODO trace2: replace "the_repository" with the actual repo instance
3149-
* that is associated with the given "istate".
3150-
*/
3151-
trace2_region_enter_printf("index", "do_write_index", the_repository,
3135+
trace2_region_enter_printf("index", "do_write_index", istate->repo,
31523136
"%s", get_lock_file_path(lock));
31533137
ret = do_write_index(istate, lock->tempfile, write_extensions, flags);
3154-
trace2_region_leave_printf("index", "do_write_index", the_repository,
3138+
trace2_region_leave_printf("index", "do_write_index", istate->repo,
31553139
"%s", get_lock_file_path(lock));
31563140

31573141
if (was_full)

0 commit comments

Comments
 (0)