git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Behaviour of 'git stash show' when a stash has untracked files
Date: Wed, 20 Sep 2017 14:33:04 +0900	[thread overview]
Message-ID: <xmqqfubinddb.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1505626069.9625.6.camel@gmail.com> (Kaartic Sivaraam's message of "Sun, 17 Sep 2017 10:57:49 +0530")

Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:

> Some time ago, I stashed a few changes along with untracked files. I
> almost forgot it until recently. Then I wanted to see what I change I
> had in the stash. So I did a 'git stash show <num>'. It worked fine but
> didn't say anything about the untracked files in that stash. That made
> me wonder where the untracked files I added went. I then applied the
> stash to see that they were still there but weren't listed in show.
>
> I understand that they aren't listed because 'git stash show' is
> typically a "diff between the stashed state and its original parent" as
> the documentation says but shouldn't there be at least a message that
> the stash contains untracked files? Those untracked files are "part of
> the stash" and I see no way to get information about their presence
> currently.
>
> So, should this behaviour be changed?

Hmm, crickets tell us that nobody is all that interested in this, it
seems.  I do not think I'd be against a new feature that lets users
ask what untracked paths are in the stash (and even their contents),
but I do think it is a bad idea to change a vanilla "stash show" to
show that information in addition to what is currently shown.

Two things need to be designed carefuly.  One is the UI to _invoke_
the new feature, the other is the output from the new feature.

As to the invocation, an obvious pair of choices are:

 - "git stash show-untracked stash@{0} [ [--] <pathspec>]"?
 - "git stash show --untracked stash@{0} [ [--] <pathspec>]"?

I'd personally vote for the former, if only because the latter makes
the design more complicated.  For one thing, tying the feature to
"show" means the output _must_ be in the form of "diff" output in
order to be consistent with the normal output from the subcommand,
but a whole-file creation diff may not be the best way to show the
entire contents of an untracked file.  Also by adding it as an
option to the existing "show" command, it makes it debatable if the
output should show the contents of untracked files in addition to
the stashed changes of tracked paths, or in place of them.  Because
I suspect that viewing contents of the untracked files and the
changes to tracked paths may serve quite different purposes from the
point of view of expected use cases, I am leaning towards saying
that it is a bad idea to show contents of untracked paths in
addition to changes to tracked paths.  There probably are other
reasons why we should prefer the former, i.e. a separate subcommand
to "git stash", independent of the existing "git stash show".

Assuming that we choose to go with a separate command, the output
format from the command does not have to be in the form of patch, so
perhaps "git stash show-untracked --list" may be a way to list the
paths (and we may want -z to show the list NUL-terminated like
"ls-files" does)?  There may be other operations to help those who
want a way to learn about untracked paths in a stash.  But this is
not exactly my itch so I'll let people who do have the itch to work
on designing the details out.




  reply	other threads:[~2017-09-20  5:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-17  5:27 Behaviour of 'git stash show' when a stash has untracked files Kaartic Sivaraam
2017-09-20  5:33 ` Junio C Hamano [this message]
2017-09-20 19:36   ` Jeff King
2017-09-21  1:23     ` Junio C Hamano
2017-09-21  3:31       ` Jeff King
2017-09-23  7:11         ` Kaartic Sivaraam
2017-09-24  0:41         ` Junio C Hamano
2017-09-23  7:03     ` Kaartic Sivaraam
  -- strict thread matches above, loose matches on Subject: below --
2017-09-17  5:07 Kaartic Sivaraam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqfubinddb.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kaarticsivaraam91196@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).