Re: [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
Hi Johannes, this looks good to me, too! Cheers, Alban
Re: [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
Hi, On Tue, 23 Oct 2018, Junio C Hamano wrote: > SZEDER Gábor writes: > > >> 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. > > Yeah, we can do this as we know we'd be dealing with a commit-ish. > If we made a mistake to use a tree object to represent a stash, this > trick wouldn't have been possible ;-) > > > FWIW, all patches look good to me, barring the typo below. > > ... > >> + /* Ensure that the hash is not mistake for a number */ > > > > s/mistake/mistaken/ > > Will squash this in and add your reviewed-by before queuing. > > Thanks, both. Thank you all! Dscho
Re: [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
SZEDER Gábor writes: >> 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. Yeah, we can do this as we know we'd be dealing with a commit-ish. If we made a mistake to use a tree object to represent a stash, this trick wouldn't have been possible ;-) > FWIW, all patches look good to me, barring the typo below. > ... >> +/* Ensure that the hash is not mistake for a number */ > > s/mistake/mistaken/ Will squash this in and add your reviewed-by before queuing. Thanks, both.
Re: [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
On Mon, Oct 22, 2018 at 03:15:05PM -0700, Johannes Schindelin via GitGitGadget wrote: > From: Johannes Schindelin > > When `git stash apply ` sees an argument that consists only of > digits, it tries to be smart and interpret it as `stash@{}`. > > Unfortunately, an all-digit hash (which is unlikely but still possible) > is therefore misinterpreted as `stash@{}` 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 > --- > 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, )) > return error(_("Could not read '%s'"), path); > + /* Ensure that the hash is not mistake for a number */ s/mistake/mistaken/ > + strbuf_addstr(, "^0"); > argv_array_pushl(_apply.args, >"stash", "apply", autostash.buf, NULL); > stash_apply.git_cmd = 1; > -- > gitgitgadget
Re: [PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
On Mon, Oct 22, 2018 at 6:15 PM Johannes Schindelin via GitGitGadget wrote: > When `git stash apply ` sees an argument that consists only of > digits, it tries to be smart and interpret it as `stash@{}`. > > Unfortunately, an all-digit hash (which is unlikely but still possible) > is therefore misinterpreted as `stash@{}` 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. > > Signed-off-by: Johannes Schindelin > --- > diff --git a/builtin/rebase.c b/builtin/rebase.c > @@ -253,6 +253,8 @@ static int apply_autostash(struct rebase_options *opts) > > if (read_one(path, )) > return error(_("Could not read '%s'"), path); > + /* Ensure that the hash is not mistake for a number */ s/mistake/mistaken/
[PATCH v2 3/3] rebase (autostash): use an explicit OID to apply the stash
From: Johannes Schindelin When `git stash apply ` sees an argument that consists only of digits, it tries to be smart and interpret it as `stash@{}`. Unfortunately, an all-digit hash (which is unlikely but still possible) is therefore misinterpreted as `stash@{}` 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. Signed-off-by: Johannes Schindelin --- 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, )) return error(_("Could not read '%s'"), path); + /* Ensure that the hash is not mistake for a number */ + strbuf_addstr(, "^0"); argv_array_pushl(_apply.args, "stash", "apply", autostash.buf, NULL); stash_apply.git_cmd = 1; -- gitgitgadget