Some code cleaning
Unify code style
Use extended test instead
Suppress unimportant Git output
Better indentation in verbose output
Improve error/warning in verbose output
Do not tear down git test repository

So that we can inspect it later.
Add test to ensure HEAD synchronization
Keep HEAD in sync only when no ref is given
Refactor the clone/fetch mechanism of Git

* Improve test case coverage
* Give more detailed error information
Use 'refs/remotes/origin/HEAD' instead

No extra fetching needed and 'refs/remotes/origin/HEAD' is officially
suppported.
No dirty hack, just checkout the reference

The working directory also needs checkout.
Code reuse by 'ref=refs/remotes/origin/HEAD'
Synchronize only when HEAD needs update
Abort HEAD synchronization if local changed

'git checkout' only aborts if the checkout creates conflict, so it is
not reliable, we'd better check it ourselves.
Abort HEAD synchronization if it is diverged
Valid the reference given by URL fragment

If the reference is not valid, use remote HEAD instead.
Keep branch ref in sync with upstream

`get_fragment` will now give symbolic-full-name for refs, so we know
whether a ref is a branch or a tag.
Use 'OPT_*' for internal option holder
Clean dangling objects in the the vcs sources