-
Notifications
You must be signed in to change notification settings - Fork 140
add -p: fix checkout -p with pathological context #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Commit fecc6f3 ("add -p: adjust offsets of subsequent hunks when one is skipped", 2018-03-01) fixed adding hunks in the correct place when a previous hunk has been skipped. However it did not address patches that are applied in reverse. In that case we need to adjust the pre-image offset so that when apply reverses the patch the post-image offset is adjusted correctly. We subtract rather than add the delta as the patch is reversed (the easiest way to think about it is to consider a hunk of deletions that is skipped - in that case we want to reduce offset so we need to subtract). Signed-off-by: Phillip Wood <[email protected]>
Welcome to GitGitGadgetHi @phillipwood, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that this Pull Request has a good description, as it will be used as cover letter. Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a PR comment of the form Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions. If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox ("raw") file corresponding to the mail you want to reply to from the Git mailing list. If you use GMail, you can upload that raw mbox file via: curl -g --user "<EMailAddress>:<Password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt |
The Perl script backing `git add -p` is used not only for that command, but also for `git stash -p`, `git reset -p` and `git checkout -p`. In preparation for teaching the C version of `git add -p` to support also the latter commands, let's abstract away what is "stage" specific into a dedicated data structure describing the differences between the patch modes. As we prepare for calling the built-in `git add -p` in `run_add_interactive()` via code paths that have not let `add_config()` do its work, we have to make sure to re-parse the config using that function in those cases. Finally, please note that the Perl version tries to make sure that the diffs are only generated for the modified files. This is not actually necessary, as the calls to Git's diff machinery already perform that work, and perform it well. This makes it unnecessary to port the `FILTER` field of the `%patch_modes` struct, as well as the `get_diff_reference()` function. Signed-off-by: Johannes Schindelin <[email protected]>
/allow phillipwood |
User phillipwood is now allowed to use GitGitGadget. |
@phillipwood please note that the PR description (i.e. the title plus the first comment) will be used as cover letter... you might want to edit the first comment. |
Thanks @dscho, I'll edit the first comment. Thanks for all your efforts on the CI as well - it's great to be able to run tests on windows before posting to the list. |
/submit |
Submitted as [email protected] |
This branch is now known as |
This patch series was integrated into pu via git@5b124ad. |
This patch series was integrated into pu via git@7426721. |
This patch series was integrated into pu via git@c32558c. |
This patch series was integrated into pu via git@33b8138. |
This patch series was integrated into pu via git@172874c. |
This patch series was integrated into pu via git@0648743. |
This patch series was integrated into pu via git@3fe6252. |
This patch series was integrated into next via git@63e063d. |
This patch series was integrated into pu via git@cb45d0a. |
This patch series was integrated into pu via git@f26fc54. |
This patch series was integrated into pu via git@d2367d8. |
This patch series was integrated into pu via git@9009ffa. |
This patch series was integrated into pu via git@af0c776. |
This patch series was integrated into pu via git@e58fb3b. |
This patch series was integrated into pu via git@a97d1f9. |
This patch series was integrated into pu via git@12bd157. |
This patch series was integrated into pu via git@1b074e1. |
This patch series was integrated into next via git@1b074e1. |
This patch series was integrated into master via git@1b074e1. |
Closed via 1b074e1. |
When I fixed the hunk offsets in add -p when hunks are skipped I forgot that the reverse patch case needs to be handled differently.