~jan0sch/darcs-book
Showing details for patch ca40267f91a17f77fb4024e26d631ad2ab2aafce.
diff -rN -u old-darcs-book/en/07-rewriting-history.md new-darcs-book/en/07-rewriting-history.md --- old-darcs-book/en/07-rewriting-history.md 2024-11-23 21:09:37.249842750 +0000 +++ new-darcs-book/en/07-rewriting-history.md 2024-11-23 21:09:37.249842750 +0000 @@ -393,6 +393,69 @@ should not do this with patches you have already published. Just like `amend` this operation is **local only**. +Unrecording individual changes +------------------------------ + +In the previous sections we have met `amend` and `unrecord` and sometimes it +would be great if we could bring those two functionalities together. Image you +have recorded a patch but instead of adding something to it by using `amend` you +would like to get rid of a change in that patch. Right now we only know how to +add things to a patch by using `amend` or `unrecord` to get right of the whole +thing. So here's a situation where things went a bit wrong. We have recorded a +patch and added a change that we didn't really want. + +``` +patch 319dfd6efb2f69bcb5205263aa716cfe6e5d54ea +Author: raichoo@example.com +Date: Mon Jul 16 20:20:28 CEST 2018 + * adding some stuff + hunk ./file.txt 1 + +I want to add this + hunk ./file.txt 3 + +but not this… +``` + +So one possibility would be to `unrecord` the whole patch and `record` it again, +this time without the change that we didn't want to have in there. In this +situation that might not be that big of an issue, but if we had a larger patch +and only wanted to get rid of a single line this approach is unacceptable. +However, `amend` has a very handy `--unrecord` flag that allows us to `unrecord` +individual changes from a patch. Super useful! + +``` +$ darcs amend --unrecord +patch 319dfd6efb2f69bcb5205263aa716cfe6e5d54ea +Author: raichoo@example.com +Date: Mon Jul 16 20:20:28 CEST 2018 + * adding some stuff +Shall I amend this patch? [yNjk...], or ? for more options: y +hunk ./file.txt 1 ++I want to add this +Shall I unrecord this change? (1/2) [ynW...], or ? for more options: n +hunk ./file.txt 3 ++but not this… +Shall I unrecord this change? (2/2) [ynW...], or ? for more options: y +Do you want to Unrecord these changes? [Yglqk...], or ? for more options: y +Finished amending patch: +patch 796db1adfd5a11c00feec4ee50fff63e4fd4ddd1 +Author: raichoo@example.com +Date: Mon Jul 16 20:25:22 CEST 2018 + * adding some stuff +$ darcs log -v --last 1 +patch 796db1adfd5a11c00feec4ee50fff63e4fd4ddd1 +Author: raichoo@example.com +Date: Mon Jul 16 20:25:22 CEST 2018 + * adding some stuff + hunk ./file.txt 1 + +I want to add this +$ darcs whatsnew +hunk ./file.txt 3 ++but not this… +``` + +That's a lot more convenient and this way we can make a lot less mistakes than +if we were to re-record our patch. + OB-LIT-E-RATE! --------------