Web lists-archives.com

Re: git add --intent-to-add + git stash "Cannot save the current worktree state"

Anthony Sottile <asottile@xxxxxxxxx> writes:

> Minimal reproduction
> ```
> git init t
> git -C t commit --allow-empty -m 'initial commit'
> touch t/a
> git -C t add --intent-to-add a
> git -C t stash
> ```
> ```
> + git init t
> Initialized empty Git repository in /private/tmp/t/t/.git/
> + git -C t commit --allow-empty -m 'initial commit'
> [master (root-commit) 858132e] initial commit
> + touch t/a
> + git -C t add --intent-to-add a
> + git -C t stash
> error: Entry 'a' not uptodate. Cannot merge.
> Cannot save the current worktree state
> ```

This is one of the well-known fundamental limitations of the design
of "git stash".

States in the index like "it is known that this path would be added
with some contents, but not quite added yet as the final contents
have not been decided (aka intent-to-add)" and "there are
conflicting wishes for the contents for this path and the final
decision has not bee made (aka unmerged)" cannot be left undecided
before getting written to a tree object (hence a commit object that
is used to represent a stash entry).