fix: path resolution, wasted git call, getConflictStatus perf#4
Open
sulthonzh wants to merge 1 commit into
Open
fix: path resolution, wasted git call, getConflictStatus perf#4sulthonzh wants to merge 1 commit into
sulthonzh wants to merge 1 commit into
Conversation
…l, optimize getConflictStatus - ConflictResolver now accepts cwd and resolves all file paths relative to workingDir instead of CWD — fixes file-not-found when run from a directory different from the git repo root - GitOperations.getConflictedFiles() no longer makes a wasted git.status() call whose result was discarded - getConflictStatus() consolidated: single status call + single diff instead of 3 separate git process invocations (getConflictedFiles + getMergeInfo → getCurrentBranch → git.status)
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.
What's wrong on main
Bug: path resolution uses CWD instead of workingDir
ConflictResolverresolves file paths withresolve(filePath)which usesprocess.cwd(). ButGitOperationshas aworkingDirthat can differ from CWD. When run from a different directory than the git repo root,validateResolution,openInEditor, andgetConflictCountall fail to find the files.Bug: wasted git.status() call
getConflictedFiles()callsthis.git.status()then throws away the result — pure waste (one process spawn for nothing).Perf: getConflictStatus makes 3+ git calls
getConflictStatus()callsgetConflictedFiles()+getMergeInfo()→getCurrentBranch()→git.status(). That's at minimum 3 separate git process invocations that could be consolidated.Fixes
ConflictResolvernow accepts optionalcwdparam and resolves all paths viaresolve(this.workingDir, filePath)git.status()call fromgetConflictedFiles()getConflictStatus()inlined: singlegit.status()+ singlegit.diff()+ reads merge state files directlyComplements
This PR is independent of and builds on PRs #2 and #3 (which fix editor splitting, conflict detection, abort handling, and rebase context).