Then I can just remove the rest of Git’s garbage and I’m done: static void WritePackageConfig(const String& packageName) I have to remove ValidateFreshName(): static void WritePackageConfig(const String& packageName) Now “the only” thing I have to do is to compare the middle block with the top one (in my case) and apply this diff to the code outside the markers. Once I’ve made my decision, I just take the more difficult change by removing the below Git marker (in my case): static void WritePackageConfig(const String& packageName) In this case the less difficult is clearly the removal of ValidateFreshName() (middle to top). I significantly simplify that by splitting both changes in the less-difficult and the more-difficult one. Now I have to apply both changes, at the top and at the bottom, to the merge-base in the middle. (Actually ValidateFreshName() is being added in v2.14.x, but if we’d revert everything back to v2.12.x, we’d really remove that function.) On the other side 362adcab1, compared to the merge-base, adds a parameter to TryActivateStageCallback(). e.: The HEAD (v2.12.x), compared to the merge-base (v2.14.x), has “removed” ValidateFreshName(). Much better! Now there’s also the merge-base in the middle. Because of this I get the conflict in this format instead: static void WritePackageConfig(const String& packageName) Or, my preferred solution: Before any of the above operations I’ve done git config -global nflictStyle diff3 (once). At this point I can look up 362adcab1 and search for that location. So let’s just use the below one, right? Wrong! That wouldn’t even compile as there’s no ValidateFreshName() in Icinga v2.12.x. The below one even seem to be an addition to the above one. ![]() On the first sight this seems like yet another additional-only pair of changes. ![]() > 362adcab1 (ConfigPackageUtility: Don't reset ongoing package updates on config validation success and process is going to be reloaded) ![]() Static bool ValidateFreshName(const String& name) Static void WriteStageConfig(const String& packageName, const String& stageName) If I checkout v2.12.6 and git cherry-pick 575af4c98 362adcab1 6193a911b, I get the following conflict in lib/remote/configpackageutility.hpp: static void WritePackageConfig(const String& packageName) Let’s imagine we’re about to release v2.12.7 and I have to backport (cherry-pick) #9267. Now, as we’ve warmed up, let’s have a look at a little more complicated example in a real-world repository – Icinga 2. While actually performing the above merge I had to re-sort the list to keep it in alphabetical order. In this simple case it’s even not enough to just remove Git’s markers despite the changes from both sides are only additional. In this case the git merge command fails and “merges” the animals as follows: -1,2 -1,2 +1,6 cat Git won’t produce the top commit as above by itself as it can’t know which animal(s) have to appear in which order. ![]() And only because of the latter Git is able to automatically merge the two branches into the top commit.Įxactly that is not possible in the second example as both rabbit and dog get added directly below cat. Then the Git history diverges: Both a cat and a rabbit get added independently of each other to different locations. The above alphabetically sorted list of pets starts with the bottom commit adding a dog. Warming upįirst let’s brush up on merge conflicts with some shortened logs from this example Git repository: In this post I’m going to share my findings as well as practical examples. I also don’t, but I’ve found a scheme how to reduce the built-in headache. Nobody likes resolving merge/rebase/cherry-pick conflicts.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |