Subject: Re: Git reference git stash

From: Junio C Hamano <[email-masked]>
Date: Fri, 06 Mar 2026 13:50:00 -0800

erik88 <[email-masked]> 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.