Fix some memory bugs.

* Initialize index structure when index file doesn't exist.
* Use g_hash_table_replace instead of _insert when key and value are the same.
[client] Fix a bug in creating commits.

Test case:
Add a file larger than 100MB, after uploading the file,
the repo will continuouly get into committing state without anything to commit.