All of lore.kernel.org
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Alban Gruin <alban.gruin@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
Date: Tue, 23 Oct 2018 00:32:56 +0200	[thread overview]
Message-ID: <20181022223256.GI30222@szeder.dev> (raw)
In-Reply-To: <07140a71dd9ed3f709970f0ce5eb6aa014417b25.1540246499.git.gitgitgadget@gmail.com>

On Mon, Oct 22, 2018 at 03:15:05PM -0700, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> When `git stash apply <argument>` sees an argument that consists only of
> digits, it tries to be smart and interpret it as `stash@{<number>}`.
> 
> Unfortunately, an all-digit hash (which is unlikely but still possible)
> is therefore misinterpreted as `stash@{<n>}` reflog.
> 
> To prevent that from happening, let's append `^0` after the stash hash,
> to make sure that it is interpreted as an OID rather than as a number.

Oh, this is clever.

FWIW, all patches look good to me, barring the typo below.

> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  builtin/rebase.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 418624837..30d58118c 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -253,6 +253,8 @@ static int apply_autostash(struct rebase_options *opts)
>  
>  	if (read_one(path, &autostash))
>  		return error(_("Could not read '%s'"), path);
> +	/* Ensure that the hash is not mistake for a number */

s/mistake/mistaken/

> +	strbuf_addstr(&autostash, "^0");
>  	argv_array_pushl(&stash_apply.args,
>  			 "stash", "apply", autostash.buf, NULL);
>  	stash_apply.git_cmd = 1;
> -- 
> gitgitgadget

  parent reply	other threads:[~2018-10-22 22:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <pull.52.git.gitgitgadget@gmail.com>
2018-10-22 22:15 ` [PATCH v2 0/3] Fix rebase autostash Johannes Schindelin via GitGitGadget
2018-10-22 22:15   ` [PATCH v2 1/3] rebase (autostash): avoid duplicate call to state_dir_path() Johannes Schindelin via GitGitGadget
2018-10-22 22:15   ` [PATCH v2 2/3] rebase (autostash): store the full OID in <state-dir>/autostash Johannes Schindelin via GitGitGadget
2018-10-22 22:15   ` [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash Johannes Schindelin via GitGitGadget
2018-10-22 22:25     ` Eric Sunshine
2018-10-22 22:32     ` SZEDER Gábor [this message]
2018-10-23  4:13       ` Junio C Hamano
2018-10-23  9:34         ` Johannes Schindelin
2018-10-23 17:07     ` Alban Gruin

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

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

  git send-email \
    --in-reply-to=20181022223256.GI30222@szeder.dev \
    --to=szeder.dev@gmail.com \
    --cc=alban.gruin@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.