Fix potentially dangerous use of git_path in ref.c