git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 10, 2019, 17:45 UTC
Message-ID
<xmqqy37s2yqn.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CA+dzEBmh4LdN-XFS9y9YKrDMzV_7+QpDzBA2uv9Xi80PgR5NTQ@mail.gmail.com>
Anthony Sottile <asottile@umich.edu> writes:
Show 21 quoted lines
> 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).

Previous: Anthony Sottile
Message 6 of 6 in “git add --intent-to-add + git stash "Cannot save the current worktree state"”
  1. Anthony SottileJan 3, 2019
  2. Johannes SchindelinJan 9, 2019
  3. Anthony SottileJan 9, 2019
  4. Johannes SchindelinJan 10, 2019
  5. Anthony SottileJan 10, 2019
  6. Junio C HamanoJan 10, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.