reset.c: move lock, write and commit out of update_index_refresh()