Use string_ncopy when copying ref names

Change code that updates the internal env/state variables to use
string_ncopy instead of string_copy_rev, since the latter copies atmost
40 characters. Test that both branches and tags with long names can be
succesfully checked out.

Fixes #290