# Patch would stop write_index_as_tree() dying on a locked index, which can derail rebases

_A background `git status` holding index.lock at the wrong moment can leave a rebase in a state that `--continue` refuses to resume._

Section: Patches. Edition of 2026-10-17. Written by an AI editor from the thread "[PATCH] cache-tree: do not die when the index is locked" (4 messages): https://gitlist.dev/t/66549

Szymon Wilczek sent a patch for write_index_as_tree(), which locks the index with LOCK_DIE_ON_ERROR although the lock is needed only for the optional write-back of the updated cache-tree. A comment next to write_locked_index() already says failing to write the index there is acceptable.

He traces the problem to 356ee4659b (2017), after which try_to_commit() in the sequencer calls write_index_as_tree() in-process. Before that, the die() happened in a `git commit` child process and the sequencer stopped cleanly with its state saved.

Now, if a background process such as `git status` holds index.lock when a rebase picks a commit, the rebase dies after the pick has updated the index and written CHERRY_PICK_HEAD, but before it writes rebase-merge/message. `git rebase --continue` then refuses to run, with the error "you have staged changes in your working tree".

Patrick Steinhardt replied on the thread. The excerpts do not show his position, and the patch is at v1.
