git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <gitster@pobox.com>,
	dev@kipras.org,
	Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>,
	git@vger.kernel.org
Subject: Re: [FR] Allow `git stash create` to include untracked changes
Date: Thu, 31 Oct 2019 13:40:34 +0000	[thread overview]
Message-ID: <20191031134034.GA63909@cat> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.1910290806310.46@tvgsbejvaqbjf.bet>

On 10/29, Johannes Schindelin wrote:
> So why does `git stash create -u ...` not work? Because the original
> design of `git stash create` never intended to take any command-line
> arguments other than the stash message. And that design can obviously
> not be fixed without breaking backwards compatibility.

Yup that's exactly right.  Not breaking this sort of backwards
compatibility is also why we have both 'git stash save' and 'git stash
push' nowadays.

We did have a similar conversation back when 'git stash push' was
introduced [1].  We almost decided this regression would be okay, but
in the end went with calling 'create_stash -m "$*"' internally to
circumvent the problem.  Now that somebody has an actual usecase we
may or may not find this "regression" acceptable.  I don't have a
strong opinion about it, so this is just to add a little bit of
context here.

[1]: https://public-inbox.org/git/20170206155606.xgkmhg656vuc6uki@sigill.intra.peff.net/

> What we _could_ do is to add a new command-line option to `git stash
> push` that would make it behave like the `create` subsubcommand: _not_
> update the `refs/stash` ref but instead print the commit hash.
> 
> I am not quite sure how to call this option (`--ephemeral` came to my
> mind, as the created commit is not reachable from anywhere and is hence
> subject to garbage collection).
> 
> A completely different approach would be to allow overriding the ref to
> store the stash in, with an empty value triggering the mode where the
> ref is not updated but the commit hash would be printed instead. I am
> thinking of something like `git stash -r '' push ...`, starting with
> this patch:
> 
> -- snip --
> diff --git a/builtin/stash.c b/builtin/stash.c
> index bb4f6d8d762..43b0a155b1d 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -1553,6 +1553,8 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
>  	struct argv_array args = ARGV_ARRAY_INIT;
> 
>  	struct option options[] = {
> +		OPT_STRING('r', "ref", &ref_stash, N_("ref"),
> +			   N_("override `refs/stash`")),
>  		OPT_END()
>  	};
> 
> -- snap --
> 
> The biggest trick will be to make all the code paths safe that assume
> that `ref_stash` refers to a valid ref ;-)
> 
> Ciao,
> Dscho

      reply	other threads:[~2019-10-31 13:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26 14:38 [FR] Allow `git stash create` to include untracked changes dev
2019-10-28  1:51 ` Junio C Hamano
2019-10-28 16:03   ` Kipras Melnikovas
2019-10-29  7:29   ` Johannes Schindelin
2019-10-31 13:40     ` Thomas Gummerer [this message]

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=20191031134034.GA63909@cat \
    --to=t.gummerer@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=dev@kipras.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ungureanupaulsebastian@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).