builtin/commit: fix memory leak in `prepare_index()`