So I was just making a patch to one of our files, and I saw some code that shouldn't be there (coupled with an error in the webpage caused by this rogue code). The code was added in a patch a few months ago, and then deleted by a revert of that commit about a month ago. So it really shouldn't be there.
I tried a few methods to track down where it came from:
- git blame: strangely, showed me the commit tag and message of the original commit that added the code, as if the revert never happened.
- git log -- filename: Showed all the commits I expected to be there, including the revert, but nothing after it that suggested it should reappear.
- Manual checking patches (bisect): The code reappeared in the commit directly after the revert, but when I checked out that patch, its log was totally different, and didn't have the revert.
This last observation leads me to conclude that the patch in question was a botched merge, but the commit message has no mention of a merge, and our team usually keeps the merge message that git generates.
So does that seem like the case? Was the code reintroduced by making a wrong choice during a conflict resolution? If so, is there a faster way to find this sort of thing? For example, the git blame said the code came from my original patch. But is there a way to get it to directly tell me that it got reintroduced in patch X, after the revert? How does git keep track of where each piece of code came from, if it doesn't know that it was affected during the merge? Is it capable of telling me that someone messed with that piece of code during a merge conflict? I had figured that the merge itself should have showed up in the blame.