{"thread":{"id":"65367","subject":"[PATCH] read-cache: use index state repository for trace2 logging","startedAt":"2026-03-27T10:08:09Z","lastAt":"2026-04-02T15:26:05Z","messageCount":14,"participants":["Jayesh Daga via GitGitGadget","Derrick Stolee","Junio C Hamano","jayesh0104","jayesh0104 via GitGitGadget","Jayesh Daga"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"540174","messageId":"pull.2253.git.git.1774606086325.gitgitgadget@gmail.com","threadId":"65367","inReplyTo":null,"subject":"[PATCH] read-cache: use index state repository for trace2 logging","fromName":"Jayesh Daga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-27T10:08:06Z","receivedAt":"2026-03-27T10:08:09Z","isPatch":true,"body":"From: jayesh0104 <jayeshdaga99@gmail.com>\n\nReplace uses of the_repository in trace2_data_intmax() with\nistate->repo, which represents the repository associated with\nthe index state.\n\nThis avoids relying on global repository state and aligns with\nother parts of the codebase (e.g., sparse-index.c) that pass the\nrepository instance explicitly.\n\nNo functional change intended.\n\nSigned-off-by: jayesh0104 <jayeshdaga99@gmail.com>\n---\n    [GSoC] read-cache: use index state repository for trace2 logging\n    \n    \n    HIGH LEVEL\n    ==========\n    \n    The current implementation of trace2_data_intmax() in read-cache.c\n    relies on the global the_repository instance.\n    \n    As part of the ongoing effort to \"lib-ify\" the Git codebase and reduce\n    dependence on global state, this patch transitions those calls to use\n    the repository instance associated with the index_state.\n    \n    \n    Low-level (Implementation & Justification)\n    ==========================================\n    \n    In read-cache.c, the index_state (istate) typically carries a pointer to\n    its associated repository. However, because istate->repo is not\n    guaranteed to be initialized in all code paths (e.g., certain low-level\n    utility or testing contexts), this patch implements a defensive fallback\n    pattern.\n    \n    Changes:\n    \n    Introduced a local repository pointer r that prefers istate->repo but\n    falls back to the_repository if the former is NULL.\n    \n    Updated trace2_data_intmax() calls to use this context-aware pointer.\n    \n    + struct repository *r = istate->repo ? istate->repo : the_repository;\n    - trace2_data_intmax(\"index\", the_repository, \"read/version\", istate->version);\n    + trace2_data_intmax(\"index\", r, \"read/version\", istate->version);\n    \n    \n    Benefits:\n    \n    Thread Safety & Modernization: Aligns with the project's goal of moving\n    away from the_repository.\n    \n    Robustness: The ternary fallback ensures we avoid potential NULL pointer\n    dereferences while maintaining existing logging behavior in edge cases.\n    \n    Consistency: Follows patterns seen in other modernized areas of the\n    codebase.\n    \n    \n    Summary\n    =======\n    \n    Transitioned trace2 logging in read-cache.c from global to local\n    repository context.\n    \n    Implemented a safety fallback to the_repository to handle uninitialized\n    istate->repo pointers.\n    \n    No functional changes to telemetry output are intended.\n    \n    cc :Karthik Nayak karthik.188@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2253%2Fjayesh0104%2Ftrace2-istate-repo-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2253/jayesh0104/trace2-istate-repo-v1\nPull-Request: https://github.com/git/git/pull/2253\n\n read-cache.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 5049f9baca..2c5c5165e0 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2206,6 +2206,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \tsize_t extension_offset = 0;\n \tint nr_threads, cpus;\n \tstruct index_entry_offset_table *ieot = NULL;\n+\tstruct repository *r;\n \n \tif (istate->initialized)\n \t\treturn istate->cache_nr;\n@@ -2313,9 +2314,10 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \t * TODO trace2: replace \"the_repository\" with the actual repo instance\n \t * that is associated with the given \"istate\".\n \t */\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n+\tr = istate->repo ? istate->repo : the_repository;\n+\ttrace2_data_intmax(\"index\", r, \"read/version\",\n \t\t\t   istate->version);\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n+\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n \t\t\t   istate->cache_nr);\n \n \t/*\n\nbase-commit: ca1db8a0f7dc0dbea892e99f5b37c5fe5861be71\n-- \ngitgitgadget\n"},{"id":"540177","messageId":"770465fe-c38f-45a9-b1b0-0ad682a35fab@gmail.com","threadId":"65367","inReplyTo":"pull.2253.git.git.1774606086325.gitgitgadget@gmail.com","subject":"Re: [PATCH] read-cache: use index state repository for trace2 logging","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-03-27T13:48:55Z","receivedAt":"2026-03-27T13:48:57Z","isPatch":true,"body":"On 3/27/2026 6:08 AM, Jayesh Daga via GitGitGadget wrote:\n\n>     Robustness: The ternary fallback ensures we avoid potential NULL pointer\n>     dereferences while maintaining existing logging behavior in edge cases.\n\n> +\tr = istate->repo ? istate->repo : the_repository;\n\nIf I understand correctly, it is a bug if istate->repo is NULL.\n\nDid you try running the test suite with istate->repo as a replacement for\nthe_repository in these tracing calls? Is there a legitimate scenario\nwhere this would be NULL?\n\n> +\ttrace2_data_intmax(\"index\", r, \"read/version\",\n>  \t\t\t   istate->version);\n> -\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n> +\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n>  \t\t\t   istate->cache_nr);\n\nOther than that, this is a minor improvement in the right direction. I'd\nrather that it be more complete if you are working in this file.\n\nThere are several places where we use the_repository and there is an\n'istate' right there. If this change works, then why not apply that same\ntransformation in the other places?\n\nThere are TODO comments for many of these, including the hunk you are\nediting (be sure to remove these!).\n\nThere are other cases that I see in this file:\n\n* refresh_index() uses the_repository for progress.\n\n* tweak_untracked_cache() has a local pointer 'r' that could\n  be set to istate->repo\n\n* tweak_split_index() passes the_repository to\n  repo_config_get_split_index().\n\n* do_read_index() uses the_repository when it could use\n  istate->repo.\n\n* read_index_from() uses the_repository for tracing.\n\n* verify_index_from() uses the_repository->hash_algo but\n  has an istate->repo that could be used.\n\n* do_write_index() has several instances.\n\n(At this point, I stopped taking inventory.)\n\nThere are other uses of the_repository that will be harder to remove as\nthere isn't a local istate at the time, so those aren't worth combining\nwith this kind of effort.\n\nIf you are already working in this space, then I recommend figuring out\nhow much we can rely on istate->repo and then apply that knowledge to\nthese cases as separate commits:\n\n1. Replace the uses in the trace2 calls with istate->repo\n   and delete the TODO comments.\n\n2. Replace the other uses of the_repository when an istate\n   exists already.\n\nThanks, -Stolee\n\n"},{"id":"540196","messageId":"xmqqqzp5kzj3.fsf@gitster.g","threadId":"65367","inReplyTo":"770465fe-c38f-45a9-b1b0-0ad682a35fab@gmail.com","subject":"Re: [PATCH] read-cache: use index state repository for trace2 logging","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-27T16:28:16Z","receivedAt":"2026-03-27T16:28:19Z","isPatch":true,"body":"Derrick Stolee <stolee@gmail.com> writes:\n\n> On 3/27/2026 6:08 AM, Jayesh Daga via GitGitGadget wrote:\n>\n>>     Robustness: The ternary fallback ensures we avoid potential NULL pointer\n>>     dereferences while maintaining existing logging behavior in edge cases.\n>\n>> +\tr = istate->repo ? istate->repo : the_repository;\n>\n> If I understand correctly, it is a bug if istate->repo is NULL.\n\nBecause INDEX_STATE_INIT(r) assigns the repository as the first\nthing, I tend to agree.  A (bare) repository can lack the index\nso repo->index might be NULL, but if you have an istate instance,\nit should always know which repository it came from.\n\n>> +\ttrace2_data_intmax(\"index\", r, \"read/version\",\n>>  \t\t\t   istate->version);\n>> -\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n>> +\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n>>  \t\t\t   istate->cache_nr);\n>\n> Other than that, this is a minor improvement in the right direction. I'd\n> rather that it be more complete if you are working in this file.\n\n;-)  Long timers always aim higher than posted patches.\n\n> If you are already working in this space, then I recommend figuring out\n> how much we can rely on istate->repo and then apply that knowledge to\n> these cases as separate commits:\n>\n> 1. Replace the uses in the trace2 calls with istate->repo\n>    and delete the TODO comments.\n>\n> 2. Replace the other uses of the_repository when an istate\n>    exists already.\n\nExcellent suggestion.\nThanks.\n\nBy the way, Jeyesh, do you really want to be known with a numbered\n\"jayesh0104\" as your name?  These author identities are cast in\nstone in commit objects and will stay with the project.\n\nAlso see Documentation/SubmittingPatches::[dco,real-name].\n\n"},{"id":"540260","messageId":"20260328052505.76445-1-jayeshdaga99@gmail.com","threadId":"65367","inReplyTo":"xmqqqzp5kzj3.fsf@gitster.g","subject":"Re: [PATCH] read-cache: use index state repository for trace2 logging","fromName":"jayesh0104","fromEmail":"jayeshdaga99@gmail.com","sentAt":"2026-03-28T05:25:04Z","receivedAt":"2026-03-28T05:26:23Z","isPatch":true,"body":"Hi Junio, Derrick,\n\nThanks for the detailed review and suggestions.\n\nOn the fallback to `the_repository`: I agree with your observation that `istate->repo` being NULL would indicate a bug rather than a scenario to defensively handle. My initial intent was to be conservative in case there were edge paths where `istate->repo` might not be initialized, but given that INDEX_STATE_INIT(r) sets this unconditionally, it makes sense to rely on that invariant instead of masking potential issues. I will drop the fallback and use `istate->repo` directly (and verify via the test suite).\n\nRegarding scope, Derrick’s suggestion to split this into separate commits makes sense. I’ll proceed as follows:\n\n1. A focused patch that replaces `the_repository` with `istate->repo` in the trace2 calls within this file and removes the associated TODO comments.\n\n2. A follow-up patch that replaces other uses of `the_repository` in places where an `istate` is already available (e.g., `refresh_index()`, `tweak_untracked_cache()`, `do_write_index()`, etc.), keeping changes logically grouped for easier review.\n\nI’ll also run the full test suite after removing the fallback to confirm there are no hidden assumptions.\n\nJunio, thanks also for pointing out the author identity. I’ll update it to use my real name in the next version.\n\nThanks again for the guidance.\n\nBest,\nJayesh\n"},{"id":"540263","messageId":"pull.2253.v2.git.git.1774682046750.gitgitgadget@gmail.com","threadId":"65367","inReplyTo":"pull.2253.git.git.1774606086325.gitgitgadget@gmail.com","subject":"[PATCH v2] read-cache: use istate->repo for trace2 logging","fromName":"Jayesh Daga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-28T07:14:06Z","receivedAt":"2026-03-28T07:14:09Z","isPatch":true,"body":"From: Jayesh Daga <jayeshdaga99@gmail.com>\n\ntrace2_data_intmax() calls in do_read_index() currently use the\nglobal 'the_repository' instance, even though the index_state\nalready carries an explicit repository pointer (istate->repo).\n\nindex_state instances are initialized via INDEX_STATE_INIT(r),\nwhich sets istate->repo. Using the_repository here is therefore\nredundant and obscures the actual repository context associated\nwith the index being read.\n\nIn particular, using the global repository can lead to misleading\ntrace2 output in scenarios where multiple repository instances are\nin use (such as tests or future refactoring toward better library\nboundaries), as events may be attributed to the wrong repository.\n\nSwitch these calls to use istate->repo directly, making the\nassociation between the index and its repository explicit.\n\nSince istate->repo is expected to be non-NULL, enforce this\nassumption with a BUG() check so that any violation of this\ninvariant is caught early.\n\nAlso remove the now-obsolete TODO comment.\n\nSigned-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n---\n    [GSoC] read-cache: use index state repository for trace2 logging\n    \n    \n    HIGH LEVEL\n    ==========\n    \n    trace2_data_intmax() calls in read-cache.c currently use the global\n    'the_repository' instance, even though index_state already carries an\n    explicit repository pointer (istate->repo).\n    \n    Use istate->repo directly in these calls, making the repository context\n    associated with the index explicit.\n    \n    \n    Low-level (Implementation & Justification)\n    ==========================================\n    \n    index_state instances are initialized via INDEX_STATE_INIT(r), which\n    sets istate->repo. Therefore, istate->repo is expected to be non-NULL in\n    normal code paths.\n    \n    Using the global 'the_repository' in this context is redundant and can\n    obscure the actual repository associated with the index being read.\n    \n    In particular, relying on the global repository may lead to misleading\n    trace2 output in scenarios where multiple repository instances are in\n    use (e.g., tests or future refactoring toward improved library\n    boundaries), as events could be attributed to the wrong repository.\n    \n    Changes:\n    \n     * Replace uses of the_repository in trace2_data_intmax() with\n       istate->repo\n     * Enforce the expectation that istate->repo is non-NULL via BUG()\n     * Remove the now-obsolete TODO comment\n    \n    Example:\n    \n     * trace2_data_intmax(\"index\", the_repository, \"read/version\", ...)\n    \n     * trace2_data_intmax(\"index\", istate->repo, \"read/version\", ...)\n    \n    \n    Summary\n    =======\n    \n    Use the repository associated with index_state for trace2 logging\n    instead of the global repository instance, making the repository context\n    explicit and consistent with existing initialization guarantees.\n    \n    \n    Changes since v1:\n    =================\n    \n     * Dropped fallback to the_repository; rely on istate->repo invariant\n     * Added BUG() check for NULL istate->repo\n     * Removed TODO comment\n     * Improved commit message with detailed rationale\n     * Cleaned up duplicate commits and fixed history\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2253%2Fjayesh0104%2Ftrace2-istate-repo-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2253/jayesh0104/trace2-istate-repo-v2\nPull-Request: https://github.com/git/git/pull/2253\n\nRange-diff vs v1:\n\n 1:  ba6d2add1d ! 1:  7fdfaaef9b read-cache: use index state repository for trace2 logging\n     @@\n       ## Metadata ##\n     -Author: jayesh0104 <jayeshdaga99@gmail.com>\n     +Author: Jayesh Daga <jayeshdaga99@gmail.com>\n      \n       ## Commit message ##\n     -    read-cache: use index state repository for trace2 logging\n     +    read-cache: use istate->repo for trace2 logging\n      \n     -    Replace uses of the_repository in trace2_data_intmax() with\n     -    istate->repo, which represents the repository associated with\n     -    the index state.\n     +    trace2_data_intmax() calls in do_read_index() currently use the\n     +    global 'the_repository' instance, even though the index_state\n     +    already carries an explicit repository pointer (istate->repo).\n      \n     -    This avoids relying on global repository state and aligns with\n     -    other parts of the codebase (e.g., sparse-index.c) that pass the\n     -    repository instance explicitly.\n     +    index_state instances are initialized via INDEX_STATE_INIT(r),\n     +    which sets istate->repo. Using the_repository here is therefore\n     +    redundant and obscures the actual repository context associated\n     +    with the index being read.\n      \n     -    No functional change intended.\n     +    In particular, using the global repository can lead to misleading\n     +    trace2 output in scenarios where multiple repository instances are\n     +    in use (such as tests or future refactoring toward better library\n     +    boundaries), as events may be attributed to the wrong repository.\n      \n     -    Signed-off-by: jayesh0104 <jayeshdaga99@gmail.com>\n     +    Switch these calls to use istate->repo directly, making the\n     +    association between the index and its repository explicit.\n     +\n     +    Since istate->repo is expected to be non-NULL, enforce this\n     +    assumption with a BUG() check so that any violation of this\n     +    invariant is caught early.\n     +\n     +    Also remove the now-obsolete TODO comment.\n     +\n     +    Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n      \n       ## read-cache.c ##\n      @@ read-cache.c: int do_read_index(struct index_state *istate, const char *path, int must_exist)\n     @@ read-cache.c: int do_read_index(struct index_state *istate, const char *path, in\n       \tif (istate->initialized)\n       \t\treturn istate->cache_nr;\n      @@ read-cache.c: int do_read_index(struct index_state *istate, const char *path, int must_exist)\n     - \t * TODO trace2: replace \"the_repository\" with the actual repo instance\n     - \t * that is associated with the given \"istate\".\n     - \t */\n     + \t}\n     + \tmunmap((void *)mmap, mmap_size);\n     + \n     +-\t/*\n     +-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n     +-\t * that is associated with the given \"istate\".\n     +-\t */\n      -\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n     -+\tr = istate->repo ? istate->repo : the_repository;\n     ++\tr=istate->repo;\n     ++\tif (!r)\n     ++\t    BUG(\"istate->repo is NULL in do_read_index\");\n      +\ttrace2_data_intmax(\"index\", r, \"read/version\",\n       \t\t\t   istate->version);\n      -\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n\n\n read-cache.c | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 5049f9baca..46ffb49cab 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2206,6 +2206,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \tsize_t extension_offset = 0;\n \tint nr_threads, cpus;\n \tstruct index_entry_offset_table *ieot = NULL;\n+\tstruct repository *r;\n \n \tif (istate->initialized)\n \t\treturn istate->cache_nr;\n@@ -2309,13 +2310,12 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \t}\n \tmunmap((void *)mmap, mmap_size);\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n+\tr=istate->repo;\n+\tif (!r)\n+\t    BUG(\"istate->repo is NULL in do_read_index\");\n+\ttrace2_data_intmax(\"index\", r, \"read/version\",\n \t\t\t   istate->version);\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n+\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n \t\t\t   istate->cache_nr);\n \n \t/*\n\nbase-commit: ca1db8a0f7dc0dbea892e99f5b37c5fe5861be71\n-- \ngitgitgadget\n"},{"id":"540283","messageId":"xmqqy0jbhkch.fsf@gitster.g","threadId":"65367","inReplyTo":"pull.2253.v2.git.git.1774682046750.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] read-cache: use istate->repo for trace2 logging","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-28T18:36:46Z","receivedAt":"2026-03-28T18:36:49Z","isPatch":true,"body":"\"Jayesh Daga via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Jayesh Daga <jayeshdaga99@gmail.com>\n>\n> trace2_data_intmax() calls in do_read_index() currently use the\n> global 'the_repository' instance, even though the index_state\n> already carries an explicit repository pointer (istate->repo).\n\nDrop \"currently\".  The canonical order in log messages in this\nproject is to describe the current state of the relevant part of the\ncodebase in present tense, pulling attention of readers to what the\nauthor finds problematic, and propose a solution.  And finally give\norders to somebody sitting in front of the keyboard to make the\nchange.\n\n> index_state instances are initialized via INDEX_STATE_INIT(r),\n> which sets istate->repo. Using the_repository here is therefore\n> redundant and obscures the actual repository context associated\n> with the index being read.\n\nEven worse, it could do a wrong thing, so saying \"redundant\" here\nsomewhat misses the point.\n\n> In particular, using the global repository can lead to misleading\n> trace2 output in scenarios where multiple repository instances are\n> in use (such as tests or future refactoring toward better library\n> boundaries), as events may be attributed to the wrong repository.\n\nExactly.\n\n> diff --git a/read-cache.c b/read-cache.c\n> index 5049f9baca..46ffb49cab 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -2206,6 +2206,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n>  \tsize_t extension_offset = 0;\n>  \tint nr_threads, cpus;\n>  \tstruct index_entry_offset_table *ieot = NULL;\n> +\tstruct repository *r;\n>  \n>  \tif (istate->initialized)\n>  \t\treturn istate->cache_nr;\n> @@ -2309,13 +2310,12 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n>  \t}\n>  \tmunmap((void *)mmap, mmap_size);\n>  \n> -\t/*\n> -\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n> -\t * that is associated with the given \"istate\".\n> -\t */\n> -\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n> +\tr=istate->repo;\n\nHave SP on both sides of an assignment operator '=', i.e.\n\n\tr = istate->repo;\n\n> +\tif (!r)\n> +\t    BUG(\"istate->repo is NULL in do_read_index\");\n> +\ttrace2_data_intmax(\"index\", r, \"read/version\",\n>  \t\t\t   istate->version);\n> -\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n> +\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n>  \t\t\t   istate->cache_nr);\n\nOr you can do without an intermediate variable 'r'.  Replacing\n\"the_repository\" with \"istate->repo\" would make the resulting line\nshorter already, and more importantly, readers do not have to\nremember that 'r' is an alias for 'istate->repo' while reading the\ncode.\n\nThanks.\n\n\n"},{"id":"540328","messageId":"d1afbb2c-84d2-45da-ade5-c86397bd24de@gmail.com","threadId":"65367","inReplyTo":"xmqqy0jbhkch.fsf@gitster.g","subject":"Re: [PATCH v2] read-cache: use istate->repo for trace2 logging","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-03-29T14:57:21Z","receivedAt":"2026-03-29T14:57:24Z","isPatch":true,"body":"On 3/28/2026 2:36 PM, Junio C Hamano wrote:\n> \"Jayesh Daga via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n>> -\t/*\n>> -\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n>> -\t * that is associated with the given \"istate\".\n>> -\t */\n>> -\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n>> +\tr=istate->repo;\n> \n> Have SP on both sides of an assignment operator '=', i.e.\n> \n> \tr = istate->repo;\n> \n>> +\tif (!r)\n>> +\t    BUG(\"istate->repo is NULL in do_read_index\");\n>> +\ttrace2_data_intmax(\"index\", r, \"read/version\",\n>>  \t\t\t   istate->version);\n>> -\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n>> +\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n>>  \t\t\t   istate->cache_nr);\n> \n> Or you can do without an intermediate variable 'r'.  Replacing\n> \"the_repository\" with \"istate->repo\" would make the resulting line\n> shorter already, and more importantly, readers do not have to\n> remember that 'r' is an alias for 'istate->repo' while reading the\n> code.\n\nAnd I don't think we need these BUG() statements, so I'm sorry if\nthat was inferred from my statement. This kind of bug isn't\nsomething that a developer will stumble upon by accidentally\ncalling the method incorrectly, but instead would be a substantial\nbreak of the index_state structure. A segfault would be enough to\ncatch this in testing.\n\nHave you thought about applying this pattern to the rest of the\ntrace2 statements in this file? Or did you want review to solidify\non this section first?\n\nThanks,\n-Stolee\n\n"},{"id":"540407","messageId":"pull.2253.v3.git.git.1774891667.gitgitgadget@gmail.com","threadId":"65367","inReplyTo":"pull.2253.v2.git.git.1774682046750.gitgitgadget@gmail.com","subject":"[PATCH v3 0/2] [GSoC] read-cache: use index state repository for trace2 logging","fromName":"Jayesh Daga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-30T17:27:45Z","receivedAt":"2026-03-30T17:27:50Z","isPatch":true,"body":"trace2 calls in read-cache.c use the global 'the_repository', even though\nthe relevant index_state provides an explicit repository pointer via\n'istate->repo'.\n\nUsing the global repository can result in incorrect trace2 output when\nmultiple repository instances are in use, as events may be attributed to the\nwrong repository.\n\nUse 'istate->repo' instead in these call sites to ensure correct repository\nattribution.\n\nChanges since v2:\n\n * Apply the change consistently across read-cache.c\n * Drop unnecessary intermediate variable\n * Remove obsolete TODO comments\n * Update commit message\n\nJayesh Daga (1):\n  read-cache: use istate->repo for trace2 logging\n\njayesh0104 (1):\n  repo: add paths.git_dir repo info key\n\n Documentation/git-repo.adoc |  5 +++++\n builtin/repo.c              |  7 +++++++\n read-cache.c                | 32 ++++++++------------------------\n t/t1900-repo-info.sh        | 10 ++++++++++\n 4 files changed, 30 insertions(+), 24 deletions(-)\n\n\nbase-commit: ca1db8a0f7dc0dbea892e99f5b37c5fe5861be71\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2253%2Fjayesh0104%2Ftrace2-istate-repo-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2253/jayesh0104/trace2-istate-repo-v3\nPull-Request: https://github.com/git/git/pull/2253\n\nRange-diff vs v2:\n\n -:  ---------- > 1:  5a8165b05d repo: add paths.git_dir repo info key\n 1:  7fdfaaef9b ! 2:  9bb6d0fa01 read-cache: use istate->repo for trace2 logging\n     @@ Metadata\n       ## Commit message ##\n          read-cache: use istate->repo for trace2 logging\n      \n     -    trace2_data_intmax() calls in do_read_index() currently use the\n     -    global 'the_repository' instance, even though the index_state\n     -    already carries an explicit repository pointer (istate->repo).\n     +    trace2 calls in read-cache.c use the global 'the_repository',\n     +    even though the relevant index_state provides an explicit\n     +    repository pointer via 'istate->repo'.\n      \n     -    index_state instances are initialized via INDEX_STATE_INIT(r),\n     -    which sets istate->repo. Using the_repository here is therefore\n     -    redundant and obscures the actual repository context associated\n     -    with the index being read.\n     +    Using the global repository can result in incorrect trace2\n     +    output when multiple repository instances are in use, as\n     +    events may be attributed to the wrong repository.\n      \n     -    In particular, using the global repository can lead to misleading\n     -    trace2 output in scenarios where multiple repository instances are\n     -    in use (such as tests or future refactoring toward better library\n     -    boundaries), as events may be attributed to the wrong repository.\n     -\n     -    Switch these calls to use istate->repo directly, making the\n     -    association between the index and its repository explicit.\n     -\n     -    Since istate->repo is expected to be non-NULL, enforce this\n     -    assumption with a BUG() check so that any violation of this\n     -    invariant is caught early.\n     -\n     -    Also remove the now-obsolete TODO comment.\n     +    Use 'istate->repo' instead to ensure correct repository\n     +    attribution.\n      \n          Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n      \n       ## read-cache.c ##\n     -@@ read-cache.c: int do_read_index(struct index_state *istate, const char *path, int must_exist)\n     - \tsize_t extension_offset = 0;\n     - \tint nr_threads, cpus;\n     - \tstruct index_entry_offset_table *ieot = NULL;\n     -+\tstruct repository *r;\n     - \n     - \tif (istate->initialized)\n     - \t\treturn istate->cache_nr;\n      @@ read-cache.c: int do_read_index(struct index_state *istate, const char *path, int must_exist)\n       \t}\n       \tmunmap((void *)mmap, mmap_size);\n     @@ read-cache.c: int do_read_index(struct index_state *istate, const char *path, in\n      -\t * that is associated with the given \"istate\".\n      -\t */\n      -\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n     -+\tr=istate->repo;\n     -+\tif (!r)\n     -+\t    BUG(\"istate->repo is NULL in do_read_index\");\n     -+\ttrace2_data_intmax(\"index\", r, \"read/version\",\n     ++\ttrace2_data_intmax(\"index\", istate->repo, \"read/version\",\n       \t\t\t   istate->version);\n      -\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n     -+\ttrace2_data_intmax(\"index\", r, \"read/cache_nr\",\n     ++\ttrace2_data_intmax(\"index\", istate->repo, \"read/cache_nr\",\n       \t\t\t   istate->cache_nr);\n       \n       \t/*\n     +@@ read-cache.c: int read_index_from(struct index_state *istate, const char *path,\n     + \tif (istate->initialized)\n     + \t\treturn istate->cache_nr;\n     + \n     +-\t/*\n     +-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n     +-\t * that is associated with the given \"istate\".\n     +-\t */\n     +-\ttrace2_region_enter_printf(\"index\", \"do_read_index\", the_repository,\n     ++\ttrace2_region_enter_printf(\"index\", \"do_read_index\", istate->repo,\n     + \t\t\t\t   \"%s\", path);\n     + \ttrace_performance_enter();\n     + \tret = do_read_index(istate, path, 0);\n     + \ttrace_performance_leave(\"read cache %s\", path);\n     +-\ttrace2_region_leave_printf(\"index\", \"do_read_index\", the_repository,\n     ++\ttrace2_region_leave_printf(\"index\", \"do_read_index\", istate->repo,\n     + \t\t\t\t   \"%s\", path);\n     + \n     + \tsplit_index = istate->split_index;\n     +@@ read-cache.c: static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n     + \tistate->timestamp.nsec = ST_MTIME_NSEC(st);\n     + \ttrace_performance_since(start, \"write index, changed mask = %x\", istate->cache_changed);\n     + \n     +-\t/*\n     +-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n     +-\t * that is associated with the given \"istate\".\n     +-\t */\n     +-\ttrace2_data_intmax(\"index\", the_repository, \"write/version\",\n     ++\ttrace2_data_intmax(\"index\", istate->repo, \"write/version\",\n     + \t\t\t   istate->version);\n     +-\ttrace2_data_intmax(\"index\", the_repository, \"write/cache_nr\",\n     ++\ttrace2_data_intmax(\"index\", istate->repo, \"write/cache_nr\",\n     + \t\t\t   istate->cache_nr);\n     + \n     + \tret = 0;\n     +@@ read-cache.c: static int do_write_locked_index(struct index_state *istate,\n     + \t\treturn ret;\n     + \t}\n     + \n     +-\t/*\n     +-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n     +-\t * that is associated with the given \"istate\".\n     +-\t */\n     +-\ttrace2_region_enter_printf(\"index\", \"do_write_index\", the_repository,\n     ++\ttrace2_region_enter_printf(\"index\", \"do_write_index\", istate->repo,\n     + \t\t\t\t   \"%s\", get_lock_file_path(lock));\n     + \tret = do_write_index(istate, lock->tempfile, write_extensions, flags);\n     +-\ttrace2_region_leave_printf(\"index\", \"do_write_index\", the_repository,\n     ++\ttrace2_region_leave_printf(\"index\", \"do_write_index\", istate->repo,\n     + \t\t\t\t   \"%s\", get_lock_file_path(lock));\n     + \n     + \tif (was_full)\n\n-- \ngitgitgadget\n"},{"id":"540408","messageId":"5a8165b05dad6143c910105be832bdc6ea5bf598.1774891667.git.gitgitgadget@gmail.com","threadId":"65367","inReplyTo":"pull.2253.v3.git.git.1774891667.gitgitgadget@gmail.com","subject":"[PATCH v3 1/2] repo: add paths.git_dir repo info key","fromName":"jayesh0104 via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-30T17:27:46Z","receivedAt":"2026-03-30T17:27:52Z","isPatch":true,"body":"From: jayesh0104 <jayeshdaga99@gmail.com>\n\nIntroduce a new repo info key `paths.git_dir` to expose the\nrepository's gitdir path, equivalent to `git rev-parse --git-dir`.\n\nThis improves consistency and allows tools to retrieve the gitdir\npath without invoking external commands.\n\nThe implementation adds support in repo.c and integrates it into\nthe repo info reporting mechanism. Documentation is updated to\ndescribe the new key, and tests are added to verify that the value\nmatches the output of `git rev-parse --git-dir`.\n\nSigned-off-by: jayesh0104 <jayeshdaga99@gmail.com>\n---\n Documentation/git-repo.adoc |  5 +++++\n builtin/repo.c              |  7 +++++++\n t/t1900-repo-info.sh        | 10 ++++++++++\n 3 files changed, 22 insertions(+)\n\ndiff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc\nindex 42262c1983..d17d911ec6 100644\n--- a/Documentation/git-repo.adoc\n+++ b/Documentation/git-repo.adoc\n@@ -95,6 +95,11 @@ In order to obtain a set of values from `git repo info`, you should provide\n the keys that identify them. Here's a list of the available keys and the\n values that they return:\n \n+`paths.git_dir`::\n+\tThe path to the Git directory for the repository (equivalent to\n+\t`git rev-parse --git-dir`).\n+\n+\n `layout.bare`::\n \t`true` if this is a bare repository, otherwise `false`.\n \ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 55f9b9095c..3067107cad 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -66,11 +66,18 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)\n \treturn 0;\n }\n \n+static int get_paths_git_dir(struct repository *repo, struct strbuf *buf)\n+{\n+\tstrbuf_addstr(buf, repo_get_git_dir(repo));\n+\treturn 0;\n+}\n+\n /* repo_info_field keys must be in lexicographical order */\n static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"paths.git_dir\", get_paths_git_dir },\n \t{ \"references.format\", get_references_format },\n };\n \ndiff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh\nindex a9eb07abe8..63be0849c4 100755\n--- a/t/t1900-repo-info.sh\n+++ b/t/t1900-repo-info.sh\n@@ -149,4 +149,14 @@ test_expect_success 'git repo info --keys uses lines as its default output forma\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'paths.git_dir matches rev-parse --git-dir' '\n+\tgit init repo &&\n+\t(\n+\t\tcd repo &&\n+\t\tgit repo info paths.git_dir >actual &&\n+\t\techo \"paths.git_dir=$(git rev-parse --git-dir)\" >expect &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"540409","messageId":"9bb6d0fa01d083daf0570c0c33a5610f51796497.1774891667.git.gitgitgadget@gmail.com","threadId":"65367","inReplyTo":"pull.2253.v3.git.git.1774891667.gitgitgadget@gmail.com","subject":"[PATCH v3 2/2] read-cache: use istate->repo for trace2 logging","fromName":"Jayesh Daga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-30T17:27:47Z","receivedAt":"2026-03-30T17:27:53Z","isPatch":true,"body":"From: Jayesh Daga <jayeshdaga99@gmail.com>\n\ntrace2 calls in read-cache.c use the global 'the_repository',\neven though the relevant index_state provides an explicit\nrepository pointer via 'istate->repo'.\n\nUsing the global repository can result in incorrect trace2\noutput when multiple repository instances are in use, as\nevents may be attributed to the wrong repository.\n\nUse 'istate->repo' instead to ensure correct repository\nattribution.\n\nSigned-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n---\n read-cache.c | 32 ++++++++------------------------\n 1 file changed, 8 insertions(+), 24 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 5049f9baca..b1074fbf06 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2309,13 +2309,9 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \t}\n \tmunmap((void *)mmap, mmap_size);\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"read/version\",\n \t\t\t   istate->version);\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"read/cache_nr\",\n \t\t\t   istate->cache_nr);\n \n \t/*\n@@ -2360,16 +2356,12 @@ int read_index_from(struct index_state *istate, const char *path,\n \tif (istate->initialized)\n \t\treturn istate->cache_nr;\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_region_enter_printf(\"index\", \"do_read_index\", the_repository,\n+\ttrace2_region_enter_printf(\"index\", \"do_read_index\", istate->repo,\n \t\t\t\t   \"%s\", path);\n \ttrace_performance_enter();\n \tret = do_read_index(istate, path, 0);\n \ttrace_performance_leave(\"read cache %s\", path);\n-\ttrace2_region_leave_printf(\"index\", \"do_read_index\", the_repository,\n+\ttrace2_region_leave_printf(\"index\", \"do_read_index\", istate->repo,\n \t\t\t\t   \"%s\", path);\n \n \tsplit_index = istate->split_index;\n@@ -3096,13 +3088,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n \tistate->timestamp.nsec = ST_MTIME_NSEC(st);\n \ttrace_performance_since(start, \"write index, changed mask = %x\", istate->cache_changed);\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_data_intmax(\"index\", the_repository, \"write/version\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"write/version\",\n \t\t\t   istate->version);\n-\ttrace2_data_intmax(\"index\", the_repository, \"write/cache_nr\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"write/cache_nr\",\n \t\t\t   istate->cache_nr);\n \n \tret = 0;\n@@ -3144,14 +3132,10 @@ static int do_write_locked_index(struct index_state *istate,\n \t\treturn ret;\n \t}\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_region_enter_printf(\"index\", \"do_write_index\", the_repository,\n+\ttrace2_region_enter_printf(\"index\", \"do_write_index\", istate->repo,\n \t\t\t\t   \"%s\", get_lock_file_path(lock));\n \tret = do_write_index(istate, lock->tempfile, write_extensions, flags);\n-\ttrace2_region_leave_printf(\"index\", \"do_write_index\", the_repository,\n+\ttrace2_region_leave_printf(\"index\", \"do_write_index\", istate->repo,\n \t\t\t\t   \"%s\", get_lock_file_path(lock));\n \n \tif (was_full)\n-- \ngitgitgadget\n"},{"id":"540418","messageId":"pull.2253.v4.git.git.1774895886678.gitgitgadget@gmail.com","threadId":"65367","inReplyTo":"pull.2253.v3.git.git.1774891667.gitgitgadget@gmail.com","subject":"[PATCH v4] read-cache: use istate->repo for trace2 logging","fromName":"Jayesh Daga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-30T18:38:06Z","receivedAt":"2026-03-30T18:38:09Z","isPatch":true,"body":"From: Jayesh Daga <jayeshdaga99@gmail.com>\n\ntrace2 calls in read-cache.c use the global 'the_repository',\neven though the relevant index_state provides an explicit\nrepository pointer via 'istate->repo'.\n\nUsing the global repository can result in incorrect trace2\noutput when multiple repository instances are in use, as\nevents may be attributed to the wrong repository.\n\nUse 'istate->repo' instead to ensure correct repository\nattribution.\n\nSigned-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n---\n    [GSoC] read-cache: use index state repository for trace2 logging\n    \n    trace2 calls in read-cache.c use the global 'the_repository', even\n    though the relevant index_state provides an explicit repository pointer\n    via 'istate->repo'.\n    \n    Using the global repository can result in incorrect trace2 output when\n    multiple repository instances are in use, as events may be attributed to\n    the wrong repository.\n    \n    Use 'istate->repo' instead in these call sites to ensure correct\n    repository attribution.\n    \n    v4:\n    \n     * reroll as clean series; drop unrelated commit.\n    \n    v2:\n    \n     * Apply the change consistently across read-cache.c\n     * Drop unnecessary intermediate variable\n     * Remove obsolete TODO comments\n     * Update commit message\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2253%2Fjayesh0104%2Ftrace2-istate-repo-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2253/jayesh0104/trace2-istate-repo-v4\nPull-Request: https://github.com/git/git/pull/2253\n\nRange-diff vs v3:\n\n 1:  5a8165b05d < -:  ---------- repo: add paths.git_dir repo info key\n 2:  9bb6d0fa01 = 1:  c99d731efa read-cache: use istate->repo for trace2 logging\n\n\n read-cache.c | 32 ++++++++------------------------\n 1 file changed, 8 insertions(+), 24 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 5049f9baca..b1074fbf06 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2309,13 +2309,9 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \t}\n \tmunmap((void *)mmap, mmap_size);\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/version\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"read/version\",\n \t\t\t   istate->version);\n-\ttrace2_data_intmax(\"index\", the_repository, \"read/cache_nr\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"read/cache_nr\",\n \t\t\t   istate->cache_nr);\n \n \t/*\n@@ -2360,16 +2356,12 @@ int read_index_from(struct index_state *istate, const char *path,\n \tif (istate->initialized)\n \t\treturn istate->cache_nr;\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_region_enter_printf(\"index\", \"do_read_index\", the_repository,\n+\ttrace2_region_enter_printf(\"index\", \"do_read_index\", istate->repo,\n \t\t\t\t   \"%s\", path);\n \ttrace_performance_enter();\n \tret = do_read_index(istate, path, 0);\n \ttrace_performance_leave(\"read cache %s\", path);\n-\ttrace2_region_leave_printf(\"index\", \"do_read_index\", the_repository,\n+\ttrace2_region_leave_printf(\"index\", \"do_read_index\", istate->repo,\n \t\t\t\t   \"%s\", path);\n \n \tsplit_index = istate->split_index;\n@@ -3096,13 +3088,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n \tistate->timestamp.nsec = ST_MTIME_NSEC(st);\n \ttrace_performance_since(start, \"write index, changed mask = %x\", istate->cache_changed);\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_data_intmax(\"index\", the_repository, \"write/version\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"write/version\",\n \t\t\t   istate->version);\n-\ttrace2_data_intmax(\"index\", the_repository, \"write/cache_nr\",\n+\ttrace2_data_intmax(\"index\", istate->repo, \"write/cache_nr\",\n \t\t\t   istate->cache_nr);\n \n \tret = 0;\n@@ -3144,14 +3132,10 @@ static int do_write_locked_index(struct index_state *istate,\n \t\treturn ret;\n \t}\n \n-\t/*\n-\t * TODO trace2: replace \"the_repository\" with the actual repo instance\n-\t * that is associated with the given \"istate\".\n-\t */\n-\ttrace2_region_enter_printf(\"index\", \"do_write_index\", the_repository,\n+\ttrace2_region_enter_printf(\"index\", \"do_write_index\", istate->repo,\n \t\t\t\t   \"%s\", get_lock_file_path(lock));\n \tret = do_write_index(istate, lock->tempfile, write_extensions, flags);\n-\ttrace2_region_leave_printf(\"index\", \"do_write_index\", the_repository,\n+\ttrace2_region_leave_printf(\"index\", \"do_write_index\", istate->repo,\n \t\t\t\t   \"%s\", get_lock_file_path(lock));\n \n \tif (was_full)\n\nbase-commit: 5361983c075154725be47b65cca9a2421789e410\n-- \ngitgitgadget\n"},{"id":"540423","messageId":"xmqqpl4ldqyi.fsf@gitster.g","threadId":"65367","inReplyTo":"pull.2253.v4.git.git.1774895886678.gitgitgadget@gmail.com","subject":"Re: [PATCH v4] read-cache: use istate->repo for trace2 logging","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-30T20:04:21Z","receivedAt":"2026-03-30T20:04:23Z","isPatch":true,"body":"\"Jayesh Daga via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Jayesh Daga <jayeshdaga99@gmail.com>\n>\n> trace2 calls in read-cache.c use the global 'the_repository',\n> even though the relevant index_state provides an explicit\n> repository pointer via 'istate->repo'.\n>\n> Using the global repository can result in incorrect trace2\n> output when multiple repository instances are in use, as\n> events may be attributed to the wrong repository.\n>\n> Use 'istate->repo' instead to ensure correct repository\n> attribution.\n>\n> Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n> ---\n> Range-diff vs v3:\n>\n>  1:  5a8165b05d < -:  ---------- repo: add paths.git_dir repo info key\n>  2:  9bb6d0fa01 = 1:  c99d731efa read-cache: use istate->repo for trace2 logging\n\nA range-diff with v2 would have been much more relevant, but the\npatch below looks super boring compared to v2 which is very good.\nJust replacing the_repository with istate->repo and nothing else,\nwhich is exactly we expect to see from the patch title above ;-)\n\nWill queue.  Thanks.\n\n"},{"id":"540743","messageId":"fbf03f6a-c746-4b6b-81fb-f3eb4b2e2f0e@gmail.com","threadId":"65367","inReplyTo":"xmqqpl4ldqyi.fsf@gitster.g","subject":"Re: [PATCH v4] read-cache: use istate->repo for trace2 logging","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-04-02T14:26:14Z","receivedAt":"2026-04-02T14:26:16Z","isPatch":true,"body":"On 3/30/26 4:04 PM, Junio C Hamano wrote:\n> \"Jayesh Daga via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n>> From: Jayesh Daga <jayeshdaga99@gmail.com>\n>>\n>> trace2 calls in read-cache.c use the global 'the_repository',\n>> even though the relevant index_state provides an explicit\n>> repository pointer via 'istate->repo'.\n>>\n>> Using the global repository can result in incorrect trace2\n>> output when multiple repository instances are in use, as\n>> events may be attributed to the wrong repository.\n>>\n>> Use 'istate->repo' instead to ensure correct repository\n>> attribution.\n>>\n>> Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n>> ---\n>> Range-diff vs v3:\n>>\n>>   1:  5a8165b05d < -:  ---------- repo: add paths.git_dir repo info key\n>>   2:  9bb6d0fa01 = 1:  c99d731efa read-cache: use istate->repo for trace2 logging\n> \n> A range-diff with v2 would have been much more relevant, but the\n> patch below looks super boring compared to v2 which is very good.\n> Just replacing the_repository with istate->repo and nothing else,\n> which is exactly we expect to see from the patch title above ;-)\n> \n> Will queue.  Thanks.\n\nThanks for putting in the work to create this complete\ncommit. LGTM.\n\n-Stolee\n"},{"id":"540769","messageId":"20260402152533.964-1-jayeshdaga99@gmail.com","threadId":"65367","inReplyTo":"fbf03f6a-c746-4b6b-81fb-f3eb4b2e2f0e@gmail.com","subject":"Re: [PATCH] read-cache: use istate->repo for trace2 logging","fromName":"Jayesh Daga","fromEmail":"jayeshdaga99@gmail.com","sentAt":"2026-04-02T15:25:33Z","receivedAt":"2026-04-02T15:26:05Z","isPatch":true,"body":"Hi Derrick,\n\nThanks for the review and for taking the time to look at this.\n\nAppreciate it!\n\nThanks,\nJayesh\n"}]}