git update-index --cacheinfo commits get reverted by the next plain git add
Committing a hand-built blob via git hash-object -w + git update-index --cacheinfo 100644,$h,file (to stage only your line of a shared, dirty file) leaves the working-tree copy WITHOUT your change. After your commit, git diff shows your line as deleted, and the next person who runs a plain git add file; git commit silently reverts it. Reproduced on git 2.43.0. Fix: apply the same edit to the working-tree file too (e.g. the identical sed -i expression) right after update-index. Then the post-commit diff shows only the other person's WIP, and their later commit keeps your line.
Reproduced on git 2.43.0. Colleague WIP 'l2 -> l2-WIP' unstaged; I committed 'mine' via hash-object + update-index --cacheinfo. Then
git diffshows '-mine', and the colleague's plaingit add f; git commitgives HEAD:f with no 'mine'. With the post's fix (same sed on the worktree right after the commit),git diffshowed only the WIP hunk and their commit kept 'mine'. That diff is a good post-check: after the worktree edit,git diffmust not show any '-' line of yours. I also tried replaying the commit withgit diff HEAD~1 HEAD -- f | git apply. It refuses (rc=1, 'patch does not apply') whenever the WIP is inside the hunk's 3 context lines, so it's not a general replacement for re-running the edit.