Repository navigation
Finish a sibling comparison when a shared entry cannot be read [patch] - #472
Merged
Merged
Conversation
DiffRepos read every tracked path both siblings share. A submodule's gitlink is a directory on disk, so File.ReadAllText threw UnauthorizedAccessException out of the background comparison task. Nothing observes that task, so SimilarReposPending stayed true and the panels showed "Comparing repositories..." forever, with nothing logged. Shared paths that are directories are now left out of the comparison, and a file that cannot be read (locked, permission denied) is left out with the reason logged. Any remaining failure still publishes an empty answer and logs why, so the pending state always ends. The single-file re-diff on the render thread uses the same non-throwing read. Fixes #436 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV
Path.Combine drops repoPath if relativePath is rooted; Path.Join never does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV
…ests The quality gate measured 77.8% coverage on new code; these two paths were the uncovered ones. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV
… new tests Addresses MSTEST0037, MSTEST0046 and MSTEST0061 reported on this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV
|
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.



Fixes #436
What was wrong
DiffReposread every tracked path that both siblings share throughReadFileOrEmpty, which caught onlyFileNotFoundExceptionandDirectoryNotFoundException. A submodule's gitlink is a directory on disk, soFile.ReadAllTextthrewUnauthorizedAccessExceptionout of the background taskCompareSiblingsAsyncstarts. Nothing observes that task, soSimilarReposPendingstayedtrue, the panels showed "Comparing repositories..." indefinitely, and nothing was logged. A locked or permission-denied file took the same path.Change
TryReadTrackedFilereplaces the read. It never throws:IOExceptionorUnauthorizedAccessExceptionreports no content, with the exception's message as the reasonDiffReposleaves out any shared path that either side can't supply content for, and logs the reason when there is one:Left <file> out of the comparison with <remote>: <reason>. Gitlinks are skipped silently, since a shared submodule is normal.DiffAgainstAllgained an optionallogparameter, whichCompareSiblingsAsyncpasses through.CompareSiblingsAsyncnow catches anything that still escapes (IOException,UnauthorizedAccessException,InvalidOperationException,ArgumentException). It publishes an empty answer so the pending state always ends, and logsComparing <remote> failed: <message>.DiffSingleFile, which runs on the render thread, goes through the same non-throwing read viaReadFileOrEmpty.Tests
Two new tests in
SimilarReposTests, both covering the acceptance criteria:SiblingsSharingASubmodulePathCompareWithTheGitlinkLeftOutadds a160000gitlink atexternalto both repos withgit update-index --cacheinfo. It checks that the comparison finishes, thatshared.txtis diffed, and thatexternalis not.ASharedFileThatCannotBeReadIsLeftOutAndLoggedholds the sibling'slocked.txtopen withFileShare.None, which is refused even under root. It checks that the comparison finishes, the readable file is still diffed, the locked one is left out, and the log names it.Results:
ProjectDirector.cschange reverted, both tests fail with the issue's exceptions:UnauthorizedAccessException: Access to the path '.../external' is deniedandIOException: ... being used by another process.CloningAnLfsRepositoryRestoresTheFileContentRatherThanThePointer, which fails the same way on unchangedmainin this sandbox.dotnet formatreports only the two issues that already exist onmain(import ordering, IDE0001 at line 1218).🤖 Generated with Claude Code
https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV
Generated by Claude Code