Fix error that occurs when a diff swaps a file for a symlink - #67
Open
AJ-505 wants to merge 1 commit into
Open
Conversation
Git writes a file-to-symlink change as two diff blocks for one path, a delete plus an add. The client turned each block into its own CodeView item, both carrying the file name as id, and CodeView threw a duplicate id error that blanked the whole page. Fold same-name entries into one item with mergeDuplicateFiles before they reach CodeView, keeping both hunks. The server already keys file hashes by name, so one entry lines up. Also stop following symlinks on the server: working-copy symlinks serve their link target for hunk expansion, comments through a symlink are refused instead of editing the target file, and shebang detection no longer reads through links.
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.
Problem
While using the app, I ran into a strange error:
Upon investigation, I realised that this behaviour only occurred on a diff that had a file which became a symlink.
Solution
Git handles these cases (files -> symlinks) specially: It produces two chunks with the same name: One with the file deleted, and the other a new file entry with the link (the one-liner pointing to the file).
Example, say we had
notes.txtthat had one line, and is now symlinked totarget.txt. The git diff output should look like this:Thus, passing that directly to
@pierre/diffs'sCodeViewthrew aduplicate iderror. The core fix is to merge the duplicates first before merging. Additionally, add guardrails on symlinks to ensure they do not get followed wrongly, or be commented on to ensure intended behavior persists.Verification
npm run testThis fix also works for symlinks converted to files as well.