public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* Git reference git stash
@ 2026-03-05 20:07 Aron Sigfridsson
  2026-03-06  2:09 ` Mirko Faina
  0 siblings, 1 reply; 5+ messages in thread
From: Aron Sigfridsson @ 2026-03-05 20:07 UTC (permalink / raw)
  To: git

Hi!

In the reference for git stash there is a section that specifies the
use of the pathspec option. It refers you to the gitglossary section
about pathspec for further information. In the glossary it states:
"See the documentation of each command for whether paths are relative
to the current directory or toplevel"

In the documentation for git stash I can't find any information about
whether it is top level or relative to current directory. Am I missing
something, or is the information not there?

Thank you for your work!

Aron

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Git reference git stash
  2026-03-05 20:07 Git reference git stash Aron Sigfridsson
@ 2026-03-06  2:09 ` Mirko Faina
  2026-03-06  2:31   ` Mirko Faina
  0 siblings, 1 reply; 5+ messages in thread
From: Mirko Faina @ 2026-03-06  2:09 UTC (permalink / raw)
  To: Aron Sigfridsson; +Cc: git

It doesn't seem to be specified at all, but from a quick test you can
see for yourself that "git stash push <pathspec>" uses relative paths
from the current directory and not the toplevel one.

To be sure on what's the relative path to use you can check the output
from "git status".

Maybe it should be added to the documentation for "git stash".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Git reference git stash
  2026-03-06  2:09 ` Mirko Faina
@ 2026-03-06  2:31   ` Mirko Faina
  2026-03-06 12:29     ` erik88
  0 siblings, 1 reply; 5+ messages in thread
From: Mirko Faina @ 2026-03-06  2:31 UTC (permalink / raw)
  To: Aron Sigfridsson; +Cc: git, Mirko Faina

On Fri, Mar 06, 2026 at 03:09:15AM +0100, Mirko Faina wrote:
> It doesn't seem to be specified at all, but from a quick test you can
> see for yourself that "git stash push <pathspec>" uses relative paths
> from the current directory and not the toplevel one.
> 
> To be sure on what's the relative path to use you can check the output
> from "git status".
> 
> Maybe it should be added to the documentation for "git stash".

Looking at the docs for other commands that use pathspec, it doesn't
look like any of them explicitly say if it's toplevel or relative
neither. I suppose the author thought it was obvious which one it was,
besides, it can be easily checked just by trying out the command.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Git reference git stash
  2026-03-06  2:31   ` Mirko Faina
@ 2026-03-06 12:29     ` erik88
  2026-03-06 21:50       ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: erik88 @ 2026-03-06 12:29 UTC (permalink / raw)
  To: Mirko Faina; +Cc: Aron Sigfridsson, git

On 26/03/06 03:31AM, Mirko Faina wrote:
> 
> Looking at the docs for other commands that use pathspec, it doesn't
> look like any of them explicitly say if it's toplevel or relative
> neither. I suppose the author thought it was obvious which one it was,
> besides, it can be easily checked just by trying out the command.
> 

Pretty sure git stash push is the only one which does pathspec

    git stash -h
    usage: git stash list [<log-options>]
       ...
       or: git stash [push [-p | --patch] [-S | --staged] [-k | --[no-]
                     [-u | --include-untracked] [-a | --all] [(-m | --m
                     [--pathspec-from-file=<file> [--pathspec-file-nul]
                     [--] [<pathspec>...]]

and pretty sure it's relative.

Sadly, git stash list does not allow a pathspec, despite the
[<log-options>]. But if you want you can do

    git log stash [<log-options>] [--] [<pathspec>]

instead, which is handy sometimes.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Git reference git stash
  2026-03-06 12:29     ` erik88
@ 2026-03-06 21:50       ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2026-03-06 21:50 UTC (permalink / raw)
  To: erik88; +Cc: Mirko Faina, Aron Sigfridsson, git

erik88 <erik88@gmail.com> writes:

> Pretty sure git stash push is the only one which does pathspec
>
>     git stash -h
>     usage: git stash list [<log-options>]
>        ...
>        or: git stash [push [-p | --patch] [-S | --staged] [-k | --[no-]
>                      [-u | --include-untracked] [-a | --all] [(-m | --m
>                      [--pathspec-from-file=<file> [--pathspec-file-nul]
>                      [--] [<pathspec>...]]
>
> and pretty sure it's relative.

In a very early days of Git, I suspect there were, but in modern
version with ":/" (or :(top)" pathspec magic, I do not think of a
need for any command (unless it cannot work from anywhere except for
the top level of the working tree for some reason) to insist taking
pathspec from the top, not relative to the directory where the user
is at.  It would break the <TAB>-completion if anything insists that
the pathspec must be relative to the top-level.

It may be a very good exercise (this can be done even by somebody
relatively new to the community, I think) to see if anything still
insists <pathspec> from the top.  And change the documentation of
the pathspec to say "unless specifically spelled out in each
command's documentation, pathspec elements are taken as relative to
the current directory" or something.

> Sadly, git stash list does not allow a pathspec, despite the
> [<log-options>]. But if you want you can do
>
>     git log stash [<log-options>] [--] [<pathspec>]
>
> instead, which is handy sometimes.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-06 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 20:07 Git reference git stash Aron Sigfridsson
2026-03-06  2:09 ` Mirko Faina
2026-03-06  2:31   ` Mirko Faina
2026-03-06 12:29     ` erik88
2026-03-06 21:50       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox