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

Re: Is it not bug git stash -- <pathspec> does not work at non-root directory?

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2017, 07:56 UTC
Message-ID
<xmqqmv3kow92.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAC2JkrLWVEHvV7tf24bPmVEDpgnrKTFtHR5UHMh+kC8v_fWumA@mail.gmail.com>
小川恭史 <aiueogawa217@gmail.com> writes:
Show 19 quoted lines
>> Please make it a habit (not limited to when interacting with
>> _this_ project) to state a bit more than "does not work";
>> instead, say "it is expected to do X, but instead it does Y, and
>> the difference between X and Y I perceive is Z".
>
> Thanks. I'll rewrite the issue.
>
> Assuming that we have sub/something and something is not included anywhere else,
>
>         cd sub && git stash -- something
>
>  is expected to make a stash for sub/something but instead returns error like
>
>         error: pathspec 'something' did not match any file(s) known to git.
>         Did you forget to 'git add'?
>
> .
>
> I don't know what I should write about 'the difference between X and Y is Z'.
If the difference between X and Y is obvious there is no need.  

I just tried it and I do not see the command is broken in the way you describe.

Trial #1 -- the command fully spelled out.
    $ git.git/master: cd Documentation
    $ Documentation/master: echo >>Makefile
    $ Documentation/master: git stash push -m "doc-make" -- Makefile
    Saved working directory and index state On master: doc-make
    $ Documentation/master: git stash show --stat 
     Documentation/Makefile | 1 +
     1 file changed, 1 insertion(+:
Trial #2 -- lazily issue the command without subcommand.
    $ git.git/master: cd Documentation
    $ Documentation/master: echo >>Makefile
    $ Documentation/master: git stash -- Makefile
    Saved working directory and index state WIP on master: 89ea799ffc Sync with maint
    $ Documentation/master: git stash show --stat 
     Documentation/Makefile | 1 +
     1 file changed, 1 insertion(+:
Trial #3 -- make sure having files with the same name is not hiding any bug.
    $ git.git/master: cd Documentation
    $ Documentation/master: echo >>CodingGuidelines
    $ Documentation/master: git stash -- CodingGuidelines
    Saved working directory and index state WIP on master: 89ea799ffc
    $ Documentation/master: git stash show --stat
     Documentation/CodingGuidelines | 1 +
      1 file changed, 1 insertion(+)
Trial #4 -- simulate a PEBKAC
    $ git.git/master: cd Documentation
    $ Documentation/master: echo >>no-such-file
    $ Documentation/master: git stash -- no-such-file
    error: pathspec 'Documentation/no-such-file' did not match any file(s) known to git.
    Did you forget to 'git add'?

The last one is an expected result---the pathspec given to the command does not match anything tracked, so without first adding the file, there is nothing for the command to do.

Previous: 小川恭史Next: 小川恭史
Message 4 of 6 in “Is it not bug git stash -- <pathspec> does not work at non-root directory?”
  1. 小川恭史Nov 18, 2017
  2. Junio C HamanoNov 18, 2017
  3. 小川恭史Nov 18, 2017
  4. Junio C HamanoNov 18, 2017
  5. 小川恭史Nov 18, 2017
  6. Junio C HamanoNov 18, 2017

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.