git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git stash filename - stashing single files.
@ 2016-12-14 13:53 Jonas Hartmann
  2016-12-14 14:44 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Hartmann @ 2016-12-14 13:53 UTC (permalink / raw)
  To: git


[-- Attachment #1.1.1: Type: text/plain, Size: 449 bytes --]

Hello,

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.

Best

-- 
Dipl.-Soz. Jonas Hartmann
HT Studios · Custom-Tailored Software-Engineering
jh@ht-studios.de
+49 160 9924 4679
http://www.ht-studios.de


[-- Attachment #1.1.2: jh.vcf --]
[-- Type: text/x-vcard, Size: 356 bytes --]

begin:vcard
fn:Dipl.-Soz. Jonas Hartmann
n:Hartmann;Jonas
org;quoted-printable:HT Studios =C2=B7 Custom-Tailored Software-Engineering;Founder
adr:;;Mainstr. 93;Pfungstadt;Hessen;64319;Germany
email;internet:jh@ht-studios.de
title:Dipl.-Soz.
tel;work:+49 160 99 24 46 79
x-mozilla-html:FALSE
url:http://www.ht-studios.de
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: git stash filename - stashing single files.
  2016-12-14 13:53 git stash filename - stashing single files Jonas Hartmann
@ 2016-12-14 14:44 ` Jeff King
  2016-12-14 15:00   ` Paul Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2016-12-14 14:44 UTC (permalink / raw)
  To: Jonas Hartmann; +Cc: git

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

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

* Re: git stash filename - stashing single files.
  2016-12-14 14:44 ` Jeff King
@ 2016-12-14 15:00   ` Paul Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Smith @ 2016-12-14 15:00 UTC (permalink / raw)
  To: Jeff King, Jonas Hartmann; +Cc: git

On Wed, 2016-12-14 at 09:44 -0500, Jeff King wrote:
> 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).

I agree that this is a terrible (and inconsistent) interface and I would
love to see it changed.

I do use messages on stashes all the time (because I can never remember
their context a week later without a hint--just looking at the diff is
not enough for me) but I would welcome this change.  Definitely the
first step would be introducing the "-m" option so people and tools
could begin the switch to using it.

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

end of thread, other threads:[~2016-12-14 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 13:53 git stash filename - stashing single files Jonas Hartmann
2016-12-14 14:44 ` Jeff King
2016-12-14 15:00   ` Paul Smith

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).