libgit2/libgit2 — pull request #1300 by carlosmn (2013-01-31 19:32:59+00:00)
Title: Crash when resolving a ref starting with "/"

This happened while developing the [Gitteh wrapper](https://github.com/jmendeth/node-gitteh). Forgive me if this has already been fixed.

Let's make a short, very short program:

```c
int status;

git_repository* repo;
status = git_repository_open(&repo, "path/to/a/repo");
//check status
git_reference* ref;
status = git_reference_lookup(&ref, "remotes/origin/HEAD");
//check status

git_reference_free(ref);
git_repository_free(repo);
```

Adjust `path/to/a/repo`, compile, run, and everything should go fine.
Now **prepend a `/` before the reference name**: `/remotes/origin/HEAD`
and the program will crash when looking up the reference:

```
nastyProg: /home/sweet/home/libgit2/src/refs.c:1626: is_all_caps_and_underscore: Assertion `name && len > 0' failed.
```

The problem is in `git_reference_normalize_name`, which calls
`is_all_caps_and_underscore` with `len = 0` because the first segment
before the `/` is an empty string.

As you can guess, `git_reference_name_to_id(... "/my/nas1y/sTrIng")`
would trigger this bug as well.