One minor thing: this should probably also call `giterr_clear()` so there isn't an old error message sitting in the error buffer.