Correct "new" id for reattached-HEAD reflog entry

1. Detach HEAD
1. Attach HEAD to a branch

**Expected:** the last reflog entry's "new" id should be the ID of `HEAD^{commit}`

**Actual:** A zero ID, like so:

```
32eab9cb1f450b5fe7ab663462b77d7f4b703344 6dcf9bf7541ee10456529833502442f385010c3d Ben Straub <bs@github.com> 1391281566 -0800   checkout: moving from master to 6dcf9bf
6dcf9bf7541ee10456529833502442f385010c3d 0000000000000000000000000000000000000000 Ben Straub <bs@github.com> 1391281663 -0800   checkout: moving from 6dcf9bf7541ee10456529833502442f385010c3d to master
```

I fixed the issue, and added more complete test coverage for detaching and reattaching HEAD.

- [x] Add a unit test exposing the bug.
- [x] Fix the bug.