feat: share fetch state across branches in the same local repo#718
Open
matt2e wants to merge 3 commits into
Open
feat: share fetch state across branches in the same local repo#718matt2e wants to merge 3 commits into
matt2e wants to merge 3 commits into
Conversation
Add a repo-level fetch cache keyed by repo path so that when multiple branches share the same local .git directory, a single git fetch satisfies all of them within the TTL window. Implements "Option C" from the plan: the repo-level TTL gates the "did we recently talk to the remote?" decision, while per-branch refspec tracking ensures any new refspecs get a cheap narrow fetch (without --prune) when the repo is already fresh. Remote projects continue using per-branch caching unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Cover normal Unix path, Windows-style path with colons, branch==base edge case, non-local prefix rejection, and too-few-segments rejection to lock in the double rsplit_once parsing invariant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
On a full fetch (TTL expired, --prune), replace the repo-level fetched_refspecs set with exactly the needed refspecs rather than extending the existing set. This prevents unbounded growth from branches that were opened and later closed. Narrow fetches (within TTL, filling gaps) continue to extend additively as before. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
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.
Summary
.gitdirectory, only one network fetch is needed per TTL window--prune)needs_fetchto consult the repo-level cache so timeline's two-stream decision stays consistentfetched_refspecswas being extended on full fetches instead of resetTest plan
repo_key_from_local_cache_keycovering normal paths, Windows paths, same branch/base, non-local keys, and too-few segments🤖 Generated with Claude Code