threads / patch / 52674

patchbuiltin/rebase: remove a call to get_oid() on `options.switch_to'

Subject: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'

## tl;dr

4 messages between Jan 21, 2020 and Feb 14, 2020. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Alban Gruin· Jan 21, 2020, 19:32 UTC · lore

When `options.switch_to' is set, `options.orig_head' is populated right after. Therefore, there is no need to parse `switch_to' again.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
 builtin/rebase.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
Show changes to builtin/rebase.c +1 −9
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 6154ad8fa5..16d2ec7ebc 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -2056,19 +2056,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		if (!(options.flags & REBASE_FORCE)) {
 			/* Lazily switch to the target branch if needed... */
 			if (options.switch_to) {
-				struct object_id oid;
-
-				if (get_oid(options.switch_to, &oid) < 0) {
-					ret = !!error(_("could not parse '%s'"),
-						      options.switch_to);
-					goto cleanup;
-				}
-
 				strbuf_reset(&buf);
 				strbuf_addf(&buf, "%s: checkout %s",
 					    getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
 					    options.switch_to);
-				if (reset_head(&oid, "checkout",
+				if (reset_head(&options.orig_head, "checkout",
 					       options.head_name,
 					       RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
 					       NULL, buf.buf) < 0) {
-- 
2.24.1
Johannes Schindelin· Jan 22, 2020, 14:00 UTC · re: Alban Gruin · lore

Re: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'

Hi Alban,
On Tue, 21 Jan 2020, Alban Gruin wrote:
> When `options.switch_to' is set, `options.orig_head' is populated right
> after.  Therefore, there is no need to parse `switch_to' again.
>
> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>

ACK! Dscho

Show 33 quoted lines
> ---
>  builtin/rebase.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 6154ad8fa5..16d2ec7ebc 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -2056,19 +2056,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  		if (!(options.flags & REBASE_FORCE)) {
>  			/* Lazily switch to the target branch if needed... */
>  			if (options.switch_to) {
> -				struct object_id oid;
> -
> -				if (get_oid(options.switch_to, &oid) < 0) {
> -					ret = !!error(_("could not parse '%s'"),
> -						      options.switch_to);
> -					goto cleanup;
> -				}
> -
>  				strbuf_reset(&buf);
>  				strbuf_addf(&buf, "%s: checkout %s",
>  					    getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
>  					    options.switch_to);
> -				if (reset_head(&oid, "checkout",
> +				if (reset_head(&options.orig_head, "checkout",
>  					       options.head_name,
>  					       RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
>  					       NULL, buf.buf) < 0) {
> --
> 2.24.1
>
>
Junio C Hamano· Jan 22, 2020, 20:47 UTC · re: Alban Gruin · lore

Re: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'

Alban Gruin <alban.gruin@gmail.com> writes:
Show 7 quoted lines
> When `options.switch_to' is set, `options.orig_head' is populated right
> after.  Therefore, there is no need to parse `switch_to' again.
>
> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
> ---
>  builtin/rebase.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
Sounds good.
Alban Gruin· Feb 14, 2020, 20:43 UTC · re: Junio C Hamano · lore

Re: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'

Hi Junio,
Le 22/01/2020 à 21:47, Junio C Hamano a écrit :
Show 12 quoted lines
> Alban Gruin <alban.gruin@gmail.com> writes:
> 
>> When `options.switch_to' is set, `options.orig_head' is populated right
>> after.  Therefore, there is no need to parse `switch_to' again.
>>
>> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
>> ---
>>  builtin/rebase.c | 10 +---------
>>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> Sounds good.
> 
Did this patch fell through the cracks?
Alban

← back to recent threads