threads / discuss / 50147

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

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

## tl;dr

6 messages between Jan 3, 2019 and Jan 10, 2019.

replies: 5people: 3as markdown or json

Anthony Sottile· Jan 3, 2019, 20:46 UTC · lore
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
```
Anthony
Johannes Schindelin· Jan 9, 2019, 18:24 UTC · re: Anthony Sottile · lore

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

Hi Anthony,
On Thu, 3 Jan 2019, Anthony Sottile wrote:
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
> ```

Apparently it is even worse. On Windows, this reportedly resulted in a segmentation fault:

https://github.com/git-for-windows/git/issues/2006

Could you cherry-pick the fix of https://github.com/git-for-windows/git/pull/2008 and see whether it fixes your use case, too?

Ciao, Johannes

P.S.: Obviously, if this PR fixes the issue, the corresponding change should be squashed into the appropriate commit in ps/stash-in-c.

Anthony Sottile· Jan 9, 2019, 18:36 UTC · re: Johannes Schindelin · lore

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

On Wed, Jan 9, 2019 at 10:25 AM Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 41 quoted lines
>
> Hi Anthony,
>
> On Thu, 3 Jan 2019, Anthony Sottile wrote:
>
> > 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
> > ```
>
> Apparently it is even worse. On Windows, this reportedly resulted in a
> segmentation fault:
>
> https://github.com/git-for-windows/git/issues/2006
>
> Could you cherry-pick the fix of
> https://github.com/git-for-windows/git/pull/2008 and see whether it fixes
> your use case, too?
>
> Ciao,
> Johannes
>
> P.S.: Obviously, if this PR fixes the issue, the corresponding change
> should be squashed into the appropriate commit in ps/stash-in-c.

I don't see a `stash.c` in ecbdaf0899161c067986e9d9d564586d4b045d62 -- the patch doesn't appear to apply

`stash` appears to be implemented as `git-stash.sh`
Anthony
Johannes Schindelin· Jan 10, 2019, 15:21 UTC · re: Anthony Sottile · lore

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

Hi Anthony,
On Wed, 9 Jan 2019, Anthony Sottile wrote:
Show 43 quoted lines
> On Wed, Jan 9, 2019 at 10:25 AM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Thu, 3 Jan 2019, Anthony Sottile wrote:
> >
> > > 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
> > > ```
> >
> > Apparently it is even worse. On Windows, this reportedly resulted in a
> > segmentation fault:
> >
> > https://github.com/git-for-windows/git/issues/2006
> >
> > Could you cherry-pick the fix of
> > https://github.com/git-for-windows/git/pull/2008 and see whether it fixes
> > your use case, too?
> >
> > P.S.: Obviously, if this PR fixes the issue, the corresponding change
> > should be squashed into the appropriate commit in ps/stash-in-c.
> 
> I don't see a `stash.c` in ecbdaf0899161c067986e9d9d564586d4b045d62 --
> the patch doesn't appear to apply
> 
> `stash` appears to be implemented as `git-stash.sh`

Whoops. I thought that you were on a different Git version, one that already has the built-in stash. My mistake.

Sorry, Johannes

Anthony Sottile· Jan 10, 2019, 16:16 UTC · re: Johannes Schindelin · lore

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

On Thu, Jan 10, 2019 at 7:21 AM Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 54 quoted lines
>
> Hi Anthony,
>
> On Wed, 9 Jan 2019, Anthony Sottile wrote:
>
> > On Wed, Jan 9, 2019 at 10:25 AM Johannes Schindelin
> > <Johannes.Schindelin@gmx.de> wrote:
> > >
> > > On Thu, 3 Jan 2019, Anthony Sottile wrote:
> > >
> > > > 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
> > > > ```
> > >
> > > Apparently it is even worse. On Windows, this reportedly resulted in a
> > > segmentation fault:
> > >
> > > https://github.com/git-for-windows/git/issues/2006
> > >
> > > Could you cherry-pick the fix of
> > > https://github.com/git-for-windows/git/pull/2008 and see whether it fixes
> > > your use case, too?
> > >
> > > P.S.: Obviously, if this PR fixes the issue, the corresponding change
> > > should be squashed into the appropriate commit in ps/stash-in-c.
> >
> > I don't see a `stash.c` in ecbdaf0899161c067986e9d9d564586d4b045d62 --
> > the patch doesn't appear to apply
> >
> > `stash` appears to be implemented as `git-stash.sh`
>
> Whoops. I thought that you were on a different Git version, one that
> already has the built-in stash. My mistake.
>
> Sorry,
> Johannes

Oh, is there a more recent version than the one mirrored at https://github.com/git/git

Anthony
Junio C Hamano· Jan 10, 2019, 17:45 UTC · re: Anthony Sottile · lore

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

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).

← back to recent threads