archive mirror
 help / color / mirror / Atom feed
From: Thomas Gummerer <>
To: Johannes Schindelin <>
Cc: Junio C Hamano <>,,
	Paul-Sebastian Ungureanu <>,
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: <>

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.


> 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 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:

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

  git send-email \
    --in-reply-to=20191031134034.GA63909@cat \ \ \ \ \ \ \
    --subject='Re: [FR] Allow `git stash create` to include untracked changes' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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 NNTP newsgroup(s).