pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/git/git/pull/2253

sets.com/assets/global-52276e82f63bb403.css" /> [GSoC] read-cache: use index state repository for trace2 logging by jayesh0104 · Pull Request #2253 · git/git · GitHub
Skip to content

[GSoC] read-cache: use index state repository for trace2 logging#2253

Open
jayesh0104 wants to merge 1 commit intogit:masterfrom
jayesh0104:trace2-istate-repo
Open

[GSoC] read-cache: use index state repository for trace2 logging#2253
jayesh0104 wants to merge 1 commit intogit:masterfrom
jayesh0104:trace2-istate-repo

Conversation

@jayesh0104
Copy link

HIGH LEVEL

The current implementation of trace2_data_intmax() in read-cache.c relies on the global the_repository instance.

As part of the ongoing effort to "lib-ify" the Git codebase and reduce dependence on global state, this patch transitions those calls to use the repository instance associated with the index_state.

Low-level (Implementation & Justification)

In read-cache.c, the index_state (istate) typically carries a pointer to its associated repository. However, because istate->repo is not guaranteed to be initialized in all code paths (e.g., certain low-level utility or testing contexts), this patch implements a defensive fallback pattern.

Changes:

Introduced a local repository pointer r that prefers istate->repo but falls back to the_repository if the former is NULL.

Updated trace2_data_intmax() calls to use this context-aware pointer.

+ struct repository *r = istate->repo ? istate->repo : the_repository;
- trace2_data_intmax("index", the_repository, "read/version", istate->version);
+ trace2_data_intmax("index", r, "read/version", istate->version);

Benefits:

Thread Safety & Modernization: Aligns with the project's goal of moving away from the_repository.

Robustness: The ternary fallback ensures we avoid potential NULL pointer dereferences while maintaining existing logging behavior in edge cases.

Consistency: Follows patterns seen in other modernized areas of the codebase.

Summary

Transitioned trace2 logging in read-cache.c from global to local repository context.

Implemented a safety fallback to the_repository to handle uninitialized istate->repo pointers.

No functional changes to telemetry output are intended.

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

Replace uses of the_repository in trace2_data_intmax() with
istate->repo, which represents the repository associated with
the index state.

This avoids relying on global repository state and aligns with
other parts of the codebase (e.g., sparse-index.c) that pass the
repository instance explicitly.

No functional change intended.

Signed-off-by: jayesh0104 <jayeshdaga99@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy