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

6 messages from 2017-11-18 to 2017-11-18. Participants: 小川恭史, Junio C Hamano.
Thread: https://gitlist.dev/t/47231

## 小川恭史, 2017-11-18 03:37

Subject: Is it not bug git stash -- <pathspec> does not work at non-root directory?
Message-ID: <CAC2Jkr+brEKLy-z45WwP2iqssA14na9xpaCoKrNKbPcTvtUxJA@mail.gmail.com>
URL: https://gitlist.dev/e/CAC2Jkr%2BbrEKLy-z45WwP2iqssA14na9xpaCoKrNKbPcTvtUxJA%40mail.gmail.com

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

```

## Junio C Hamano, 2017-11-18 03:53

Subject: Re: Is it not bug git stash -- <pathspec> does not work at non-root directory?
Message-ID: <xmqqzi7kp7j2.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqzi7kp7j2.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAC2Jkr+brEKLy-z45WwP2iqssA14na9xpaCoKrNKbPcTvtUxJA@mail.gmail.com>

```
小川恭史 <aiueogawa217@gmail.com> writes:

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

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

If you mean

	cd sub && git stash -- Makefile

does not make a stash for only sub/Makefile and instead makes (or
attempts to make) a stash for only Makefile at the top-level, then
I think it is a bug, whose likely cause is that the implementation
forgets to prepend the $prefix to the pathspec it got from the
command line.  But I am writing this without looking at the
implementation and with your unclear description of the issue, so
I may be completely off the mark ;-)

Thanks.

```

## 小川恭史, 2017-11-18 04:12

Subject: Re: Is it not bug git stash -- <pathspec> does not work at non-root directory?
Message-ID: <CAC2JkrLWVEHvV7tf24bPmVEDpgnrKTFtHR5UHMh+kC8v_fWumA@mail.gmail.com>
URL: https://gitlist.dev/e/CAC2JkrLWVEHvV7tf24bPmVEDpgnrKTFtHR5UHMh%2BkC8v_fWumA%40mail.gmail.com
In-Reply-To: <xmqqzi7kp7j2.fsf@gitster.mtv.corp.google.com>

```
> 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'.

2017-11-18 12:53 GMT+09:00 Junio C Hamano <gitster@pobox.com>:
> 小川恭史 <aiueogawa217@gmail.com> writes:
>
>> Is it not bug git stash -- <pathspec> does not work at non-root directory?
>
> 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".
>
> If you mean
>
>         cd sub && git stash -- Makefile
>
> does not make a stash for only sub/Makefile and instead makes (or
> attempts to make) a stash for only Makefile at the top-level, then
> I think it is a bug, whose likely cause is that the implementation
> forgets to prepend the $prefix to the pathspec it got from the
> command line.  But I am writing this without looking at the
> implementation and with your unclear description of the issue, so
> I may be completely off the mark ;-)
>
> Thanks.

```

## Junio C Hamano, 2017-11-18 07:56

Subject: Re: Is it not bug git stash -- <pathspec> does not work at non-root directory?
Message-ID: <xmqqmv3kow92.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqmv3kow92.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAC2JkrLWVEHvV7tf24bPmVEDpgnrKTFtHR5UHMh+kC8v_fWumA@mail.gmail.com>

```
小川恭史 <aiueogawa217@gmail.com> writes:

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


```

## 小川恭史, 2017-11-18 09:08

Subject: Re: Is it not bug git stash -- <pathspec> does not work at non-root directory?
Message-ID: <CAC2Jkr+TkqnZ+rZVxZNv80rpJHf-BBNZqXZqW+hBVZ8hRrPRSw@mail.gmail.com>
URL: https://gitlist.dev/e/CAC2Jkr%2BTkqnZ%2BrZVxZNv80rpJHf-BBNZqXZqW%2BhBVZ8hRrPRSw%40mail.gmail.com
In-Reply-To: <xmqqmv3kow92.fsf@gitster.mtv.corp.google.com>

```
I upgraded the version of git from 2.13.1 to 2.15.0 on Mac and fixed my issue.
Thanks.

2017-11-18 16:56 GMT+09:00 Junio C Hamano <gitster@pobox.com>:
> 小川恭史 <aiueogawa217@gmail.com> writes:
>
>>> 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.
>

```

## Junio C Hamano, 2017-11-18 11:36

Subject: Re: Is it not bug git stash -- <pathspec> does not work at non-root directory?
Message-ID: <xmqqine7q0n3.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqine7q0n3.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAC2Jkr+TkqnZ+rZVxZNv80rpJHf-BBNZqXZqW+hBVZ8hRrPRSw@mail.gmail.com>

```
小川恭史 <aiueogawa217@gmail.com> writes:

> I upgraded the version of git from 2.13.1 to 2.15.0 on Mac and fixed my issue.
> Thanks.

Ah, yes, that bug was fixed in the 2.14.0 timeframe but was
backported to 2.13.2 and onwards (it was a bug in 2.13.0, I think).


```
