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

4 messages from 2020-01-21 to 2020-02-14. Participants: Alban Gruin, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/52674

## Alban Gruin, 2020-01-21 19:32

Subject: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'
Message-ID: <20200121193226.24297-1-alban.gruin@gmail.com>
URL: https://gitlist.dev/e/20200121193226.24297-1-alban.gruin%40gmail.com

```
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(-)

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, 2020-01-22 14:00

Subject: Re: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'
Message-ID: <nycvar.QRO.7.76.6.2001221500210.46@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.2001221500210.46%40tvgsbejvaqbjf.bet
In-Reply-To: <20200121193226.24297-1-alban.gruin@gmail.com>

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

> ---
>  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, 2020-01-22 20:47

Subject: Re: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'
Message-ID: <xmqq1rrr6ww2.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqq1rrr6ww2.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <20200121193226.24297-1-alban.gruin@gmail.com>

```
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.

```

## Alban Gruin, 2020-02-14 20:43

Subject: Re: [PATCH v1] builtin/rebase: remove a call to get_oid() on `options.switch_to'
Message-ID: <df9ede1c-f657-d96f-2d4c-479245f2a2d8@gmail.com>
URL: https://gitlist.dev/e/df9ede1c-f657-d96f-2d4c-479245f2a2d8%40gmail.com
In-Reply-To: <xmqq1rrr6ww2.fsf@gitster-ct.c.googlers.com>

```
Hi Junio,

Le 22/01/2020 à 21:47, Junio C Hamano a écrit :
> 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



```
