git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maximilian Reichel <reichemn@icloud.com>
To: git@vger.kernel.org
Subject: 'stash push' fails after 'add -N'
Date: Tue, 5 Apr 2022 11:32:19 +0200	[thread overview]
Message-ID: <1E62EF4D-1D9C-494F-832D-EDE7A10EC665@icloud.com> (raw)

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
Running the following commands:
```
#!/bin/bash
git init workDir
cd workDir
git commit -m first --allow-empty
touch a
git add --intent-to-add a
git stash push --include-untracked
```

What did you expect to happen? (Expected behavior)
I tried to stash my changes after adding a file with `git add --intent-to-add`.
I expected the stash operation to succeed.


What happened instead? (Actual behavior)
The stash operation fails with the following output:
```
error: Entry 'a' not uptodate. Cannot merge.
Cannot save the current worktree state
```
Also, I find the error message very confusing.

It seems inconsistent whether git considers files added with
`--intent-to-add` as tracked or untracked.
Running `git status` after the commands above will show "Changes not
staged for commit: new file: a".
If I run the following commands after the commands above:
```
touch b
git add b
git stash push -S
git stash pop --index
git rm -f b
```
`git status` will now report the file `a` as untracked.

What's different between what you expected and what actually happened?
I expected `git stash push` to succeed instead of failing.

Anything else you want to add:
I tested this on git 2.35.1 and 2.21.0, which are both affected.

[System Info]
git version:
git version 2.35.1
cpu: x86_64
built from commit: 4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.10.25-linuxkit #1 SMP Tue Mar 23 09:27:39 UTC 2021 x86_64
compiler info: gnuc: 10.2
libc info: glibc: 2.31
$SHELL (typically, interactive shell): <unset>


[Enabled Hooks]
not run from a git repository - no hooks to show

                 reply	other threads:[~2022-04-05  9:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1E62EF4D-1D9C-494F-832D-EDE7A10EC665@icloud.com \
    --to=reichemn@icloud.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).