Monday, June 27, 2011

git reflog: so, what did just happen?!

Chris Aniszczyk made me aware of git reflog. I am not sure I grasp the full power yet, but I already like the fact that it shows me what I just did. For example, this is my latest output:
98e4cae HEAD@{0}: commit: Added copyright owner line for previous patch
280381d HEAD@{1}: origin/cdk-1.4.x: updating HEAD
bce19a0 HEAD@{2}: am: Fixed potential NPE.
280381d HEAD@{3}: commit (amend): Fixed potential NPE.
534dc09 HEAD@{4}: am: Fixed potential NPE.
45b67e5 HEAD@{5}: origin/cdk-1.4.x: updating HEAD
1fa4bb9 HEAD@{6}: commit: Fixed potential NPE.
cf399c8 HEAD@{7}: commit: Fixed potential NPE.
45b67e5 HEAD@{8}: HEAD~1: updating HEAD
5f8ecf9 HEAD@{9}: am: Fixed potential NPE.

What I did on these steps was to apply part of a bug fix patch by Dmitry (EPO, The Hague). In fact, the patch actually fixed two separate problems. One part fixed a NullPointerException in code by me, and that code looks fine; the other part is in code not written by me, and I cannot oversee the consequences of that patch. A unit test would help, and so would a review by the original author.

So, the goal was to apply part of the patch. So, I downloaded Dmitry's patch from GitHub (see, GitHub Tip: download commits as patches, and the hash in the bug report). Then I applied it to my local repositort (5f8ecf9, see the above list). I undid the patch with 'git reset HEAD~1' (45b67e5) to make the patch unstaged. The I committed the two patch parts separately (cf399c8 and 1fa4bb9). I then rebased on origin/cdk-1.4.x to ensure my cdk-1.4.x branch is up to date (45b67e5, and 534dc09 I guess). Then I signed off the part of the patch that I can review (280381d, and bce19a0?), and finally I updated from the upstream repository once more (280381d) and then applied a patch to add Dmitry in the Copyright header as co-author of this class (98e4cae, see also Making patches; Attribution; Copyright and License.).

Now, apparently, you can edit this log too... but I am not sure why you would go about doing that, nor what effect that will have on the commit history...

No comments:

Post a Comment