Repository navigation
Read a type change as the two sections Git prints - #122
Open
devhimanshuhc wants to merge 1 commit into
Open
devhimanshuhc wants to merge 1 commit into
devhimanshuhc wants to merge 1 commit into
Conversation
Git prints a type change, such as a file replaced by a symbolic link, as a deletion and a creation of the same path, but diff_paths recorded one entry for it. The section count then disagreed with the path metadata, so a local review and the commit and push hooks failed with "could not read the local patch's Git path metadata" instead of sending the patch for the server to judge. Record a deletion and a creation, in Git's order, so preflight reads each section against its own path.
This branch has not been deployed
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
When a tracked file changes type, every local review of the change fails with a message about the CLI's internals. Examples are a file replaced by a symbolic link, a symbolic link replaced by a file, or either replaced by a submodule:
This hits:
proofline review, with or without--staged,--include-untrackedor--path;diff().With
onIncomplete=block, the hooks block the commit or push. Nothing tells the person that the symlink is the cause.Cause
diff_pathsreadsgit diff --raw -z --patchand records onePatchPathsentry per raw record, treating statusTlikeM. Git prints a type change as two patch sections, a deletion and then a creation of the same path:diff()then compares 1 path entry with 2diff --gitlines and returnsGitError::InvalidDiff.Change
diff_pathsrecords a type change as a deletion followed by a creation, in Git's order. The path metadata then matches the sections, andpreflight::check, which pairs each section with its path in order, reads removed lines against the old file and added lines against the new one. Mode-only changes such as 644 to 755 areM, notT, and are unaffected.The public contract says the server refuses symbolic links and submodules in a patch. This change does not make them reviewable. It makes the CLI do what
diff()already intends for gitlinks ("stays in the patch for the server to refuse"): send the patch and print the server's actual reason, instead of failing locally with an error that points at the CLI.Verification
tests/local_patch.rs(Unix-only, since they create symlinks). Both fail on unmodifiedmainwith the metadata error and pass with this change:a_file_replaced_by_a_symlink_uploads_its_two_sections_for_the_server: with and without--path, one upload with bothdiff --git a/linked.txt b/linked.txtsections (deleted file mode 100644,new file mode 120000).a_secret_in_a_file_replaced_by_a_symlink_is_still_refused: secret-shaped content in the new side of a type change is still refused by the local preflight, naming the path and making no HTTP request.cargo fmt --checkandcargo clippy --locked --all-targets -- -D warningsare clean.cargo test --locked --no-fail-fastpasses everything exceptunattended_registration_preserves_settings_and_uses_the_installed_binary, which fails the same way on unmodifiedmainon macOS (unattended_registration_preserves_settings_and_uses_the_installed_binary fails on macOS (/var vs /private/var) #112).