https://github.com/libgit2/libgit2/blob/development/src/refdb_fs.c#L1047 :p