apply.c: make init_apply_state() take a struct repository