Use libgit2 for reading refs

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Introduced better error management

Signed-off-by: Sven Strickroth <email@cs-ware.de>
more and better error handling WIP

Signed-off-by: Sven Strickroth <email@cs-ware.de>