Repository navigation
Show files as conflicted in git panel when discard undo creates merge conflicts, handle various edge cases - #563
Conversation
18438f1 to
97c4d4d
Compare
For quick identificatin of files opened in editor that are previews of conflicted files
9e5c0f6 to
22458df
Compare
| mergeResult = {filePath, resultPath, conflict: true}; | ||
| } | ||
| } else if (theirsPath && !commonBasePath) { // added file | ||
| // TODO |
There was a problem hiding this comment.
What will happen if this PR gets merged before this is implemented?
| `; | ||
| if (oursSha) { indexInfo += `${fileMode} ${oursSha} 2\t${filePath}\n`; } | ||
| if (theirsSha) { indexInfo += `${fileMode} ${theirsSha} 3\t${filePath}\n`; } | ||
| return this.exec(['update-index', '--index-info'], {stdin: indexInfo}); |
There was a problem hiding this comment.
This should probably be a write op so it doesn't run in parallel with other operations.
| } else if (!otherPath && basePath) { // deleted file | ||
| // TODO: handle this | ||
| return null; | ||
| const mergeFilePromises = filePaths.map(async (filePathInfo, i) => { |
There was a problem hiding this comment.
This logic is starting to feel a little hairy again. Probably okay to merge, but I continue to wonder if there are more extractions we can do, especially around object modeling. E.g. would it make sense to have a Merge object? Or utilize Conflict-style objects like in @smashwilson's conflict resolution stuff?
There was a problem hiding this comment.
We couldn't use Conflict directly here (that's a conflict marker within a file, not an entire file that contains conflict markers). Introducing some kind of model for conflicted files (ConflictedFile?) might be worthwhile. Maybe we could even refactor some of the conflict resolution stuff to use it too.
| } | ||
|
|
||
| updateIndex(filePath, commonBaseSha, oursSha, theirsSha) { | ||
| return this.git.updateIndex(filePath, commonBaseSha, oursSha, theirsSha); |
There was a problem hiding this comment.
Is there a better method name than updateIndex for this? Yes, we're updating the index, but in a specific way. Perhaps writeMergeConflictToIndex or similar?
| notificationManager: React.PropTypes.object, | ||
| fetch: React.PropTypes.func, | ||
| push: React.PropTypes.func, | ||
| pull: React.PropTypes.func, |
There was a problem hiding this comment.
This is a note for me to remove this same change in #565
| commandRegistry={commandRegistry} | ||
| notificationManager={notificationManager} | ||
| confirm={confirm} | ||
| tooltips={tooltips} |
There was a problem hiding this comment.
😆 Yeah we all fixed this independently in our own pull requests.
smashwilson
left a comment
There was a problem hiding this comment.
Just a few bits to add.
Also: today I learned how git update-index works. That's pretty cool 😁
|
|
||
| async updateIndex(filePath, commonBaseSha, oursSha, theirsSha) { | ||
| const fileMode = await this.getFileMode(filePath); | ||
| let indexInfo = dedent` |
There was a problem hiding this comment.
Nice. I was wondering if there was a library for this but I hadn't bothered to actually look for one yet 😁
| } else if (!otherPath && basePath) { // deleted file | ||
| // TODO: handle this | ||
| return null; | ||
| const mergeFilePromises = filePaths.map(async (filePathInfo, i) => { |
There was a problem hiding this comment.
We couldn't use Conflict directly here (that's a conflict marker within a file, not an entire file that contains conflict markers). Introducing some kind of model for conflicted files (ConflictedFile?) might be worthwhile. Maybe we could even refactor some of the conflict resolution stuff to use it too.
| describe('getFileMode(filePath)', () => { | ||
| it('returns the file mode of the specified file', async () => { | ||
| const workingDirPath = await cloneRepository('three-files'); | ||
| const git = new GitShellOutStrategy(workingDirPath); |
There was a problem hiding this comment.
Should these use createTestStrategy?
| commandRegistry={commandRegistry} | ||
| notificationManager={notificationManager} | ||
| confirm={confirm} | ||
| tooltips={tooltips} |
There was a problem hiding this comment.
😆 Yeah we all fixed this independently in our own pull requests.
| workdirPath = await cloneRepository('three-files'); | ||
| repository = await buildRepository(workdirPath); | ||
|
|
||
| getFileContents = filePath => { |
There was a problem hiding this comment.
Worth adapting into the readFile helper maybe?
This responsibility is a better fit for Repository#discardWorkDirChangesForPaths
| output = (await this.exec(['hash-object', '-w', filePath], {writeOperation: true})).trim(); | ||
| } catch (e) { | ||
| output = null; | ||
| if (e.stdErr.match(/fatal: Cannot open .*: No such file or directory/)) { |
Display files under conflict in Merge Conflicts list (fixes #559)
Handle removed and added file edge cases (fixes #543)
Fix bug undoing discard for file in subdirectory (fixes #588)