[GSoC] read-cache: use index state repository for trace2 logging#2253
Open
jayesh0104 wants to merge 1 commit intogit:masterfrom
Open
[GSoC] read-cache: use index state repository for trace2 logging#2253jayesh0104 wants to merge 1 commit intogit:masterfrom
jayesh0104 wants to merge 1 commit intogit:masterfrom
Conversation
f535060 to
ba6d2ad
Compare
Author
|
/submit |
|
Submitted as pull.2253.git.git.1774606086325.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
a53fe3e to
a6afe27
Compare
trace2_data_intmax() calls in do_read_index() currently use the global 'the_repository' instance, even though the index_state already carries an explicit repository pointer (istate->repo). index_state instances are initialized via INDEX_STATE_INIT(r), which sets istate->repo. Using the_repository here is therefore redundant and obscures the actual repository context associated with the index being read. In particular, using the global repository can lead to misleading trace2 output in scenarios where multiple repository instances are in use (such as tests or future refactoring toward better library boundaries), as events may be attributed to the wrong repository. Switch these calls to use istate->repo directly, making the association between the index and its repository explicit. Since istate->repo is expected to be non-NULL, enforce this assumption with a BUG() check so that any violation of this invariant is caught early. Also remove the now-obsolete TODO comment. Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>
a6afe27 to
7fdfaae
Compare
Author
|
/submit |
|
Submitted as pull.2253.v2.git.git.1774682046750.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HIGH LEVEL
trace2_data_intmax() calls in read-cache.c currently use the global
'the_repository' instance, even though index_state already carries an
explicit repository pointer (istate->repo).
Use istate->repo directly in these calls, making the repository context
associated with the index explicit.
Low-level (Implementation & Justification)
index_state instances are initialized via INDEX_STATE_INIT(r), which sets
istate->repo. Therefore, istate->repo is expected to be non-NULL in normal
code paths.
Using the global 'the_repository' in this context is redundant and can
obscure the actual repository associated with the index being read.
In particular, relying on the global repository may lead to misleading
trace2 output in scenarios where multiple repository instances are in use
(e.g., tests or future refactoring toward improved library boundaries),
as events could be attributed to the wrong repository.
Changes:
Example:
Summary
Use the repository associated with index_state for trace2 logging instead
of the global repository instance, making the repository context explicit
and consistent with existing initialization guarantees.
Changes since v1:
cc: Karthik Nayak karthik.188@gmail.com
cc: Justin Tobler jltobler@gmail.com
cc: Ayush Chandekar ayu.chandekar@gmail.com
cc: Siddharth Asthana siddharthasthana31@gmail.com