Fix possible crash when looking for version control for directory

Task-number: QTCREATORBUG-9656

Change-Id: If8babdb942830bd11fe360a311c57b75312248be
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>