On Wed, Dec 14, 2016 at 02:53:20PM +0100, Jonas Hartmann wrote:

> http://stackoverflow.com/questions/3040833/stash-only-one-file-out-of-multiple-files-that-have-changed-with-git#comment32451416_3040833
> 
> Could it be possible to have "git stash [filename][filename]...", to
> stash only single files?
> There seems to be a broad community desire.

I think this would be useful.  You can pick and choose with "git stash
-p", but I have still often wanted "git stash -p [filename]".

There is one problem, though: any non-option arguments to "git stash
save" are interpreted as the stash message. So just:

  git stash save file

would break backwards compatibility. Annoyingly, so would:

  git stash save -- file

which uses the "--" to let you have a message which starts with a dash.

Personally, I think this is a pretty terrible interface. Besides the
fact that I have never written a stash message in all my years of using
git, it's totally inconsistent with the rest of git (which would use
"-m" for the message, and treat arguments as pathspecs).

So it might be worth changing, but we'd probably have to deal with the
backwards compatibility fallout, have a deprecation period, etc.

As for "git stash" without "save", there is magic to rewrite:

  git stash [opts]

into

  git stash save [opts]

but it explicitly does not allow non-option arguments. So:

  git stash foo

is an error (and not unreasonably, since "git stash list" creates an
ambiguity problem). Perhaps:

  git stash -- foo

could be allowed to treat "foo" as a filename. There wouldn't be any
backwards compatibility problems, though it would be weird and
inconsistent to be able to specify filenames via the "shortcut"
invocation, but not with "git stash save".

-Peff

Reply via email to