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

Re: "git-stash --keep-index" crashes when there are no tracked files

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 16, 2024, 10:39 UTC
Message-ID
<Zr8sd01HNGwd8zJC@tanuki>
In-Reply-To
<CAPM0=yCJ0snEznK0C+zkmGofWHE3OPWoMXSVGH6=TdM7=rZ84g@mail.gmail.com>
On Tue, Aug 13, 2024 at 07:36:15PM +0200, Piotr Siupa wrote:
Show 25 quoted lines
> Hello,
> 
> I've found a bug.
> It's something that's unlikely to happen in a normal workflow but it
> breaks a script I'm trying to write.
> 
> Here is the complete report from "git bugreport":
> 
> 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)
> git init
> git commit --allow-empty --message='initial commit'
> touch foo
> git stash push --include-untracked --keep-index
> 
> What did you expect to happen? (Expected behavior)
> A stash entry storing the untracked file "foo" should be created. The
> working directory and index should become empty.
> 
> What happened instead? (Actual behavior)
> The command did what was expected but after that it crashed with the
> following error message:
> error: pathspec ':/' did not match any file(s) known to git

I would clarify that this is not "crashing", but that's basically splitting hairs. In any case, thanks for this clear bug report with a nice and simple reproducer. I agree that this is something that should be fixed indeed.

Will send a patch shortly.
Patrick
Previous: Piotr SiupaNext: Patrick Steinhardt
Message 2 of 3 in “"git-stash --keep-index" crashes when there are no tracked files”
  1. Piotr SiupaAug 13, 2024
  2. Patrick SteinhardtAug 16, 2024
  3. builtin/stash: fix `--keep-index --include-untracked` with empty HEADPatrick Steinhardt, Aug 16, 2024

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.