# [PATCH 0/1] Support git pull --rebase=i <remote> <branch>

7 messages from 2018-08-04 to 2018-08-08. Participants: Johannes Schindelin via GitGitGadget, Junio C Hamano, Johannes Schindelin, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/49035

## Johannes Schindelin via GitGitGadget, 2018-08-04 19:23

Subject: [PATCH 0/1] Support git pull --rebase=i <remote> <branch>
Message-ID: <pull.14.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/pull.14.git.gitgitgadget%40gmail.com

```
The patch [https://github.com/git-for-windows/git/commit/4aa8b8c82] that
introduced support for pull --rebase=<type> into the Git for Windows project
still allowed the very convenient abbreviation

git pull --rebase=i

which was later lost when it was ported to the builtin git pull, and it was
not introduced before the patch eventually made it into Git as f5eb87b98dd
(pull: allow interactive rebase with --rebase=interactive, 2016-01-13).

However, it is really a useful short hand for the occasional rebasing pull
on branches that do not usually want to be rebased.

So let's reintroduce this convenience, at long last.

Johannes Schindelin (1):
  pull --rebase=<type>: allow single-letter abbreviations for the type

 builtin/pull.c  |  6 +++---
 t/t5520-pull.sh | 12 ++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)


base-commit: 1d89318c48d233d52f1db230cf622935ac3c69fa
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-14%2Fdscho%2Fpull-rebase-i-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-14/dscho/pull-rebase-i-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/14
-- 
gitgitgadget

```

## Johannes Schindelin via GitGitGadget, 2018-08-04 19:23

Subject: [PATCH 1/1] pull --rebase=<type>: allow single-letter abbreviations for the type
Message-ID: <d2ba1e6bef9d6d4eabc8eaa60435dcae1105fd07.1533410586.git.gitgitgadget@gmail.com>
URL: https://gitlist.dev/e/d2ba1e6bef9d6d4eabc8eaa60435dcae1105fd07.1533410586.git.gitgitgadget%40gmail.com
In-Reply-To: <pull.14.git.gitgitgadget@gmail.com>

```
From: Johannes Schindelin <johannes.schindelin@gmx.de>

Git for Windows' original 4aa8b8c8283 (Teach 'git pull' to handle
--rebase=interactive, 2011-10-21) had support for the very convenient
abbreviation

	git pull --rebase=i

which was later lost when it was ported to the builtin `git pull`, and
it was not introduced before the patch eventually made it into Git as
f5eb87b98dd (pull: allow interactive rebase with --rebase=interactive,
2016-01-13).

However, it is *really* a useful short hand for the occasional rebasing
pull on branches that do not usually want to be rebased.

So let's reintroduce this convenience, at long last.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/pull.c  |  6 +++---
 t/t5520-pull.sh | 12 ++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/builtin/pull.c b/builtin/pull.c
index 4e7893539..53bc5facf 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -48,11 +48,11 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
 		return REBASE_FALSE;
 	else if (v > 0)
 		return REBASE_TRUE;
-	else if (!strcmp(value, "preserve"))
+	else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
 		return REBASE_PRESERVE;
-	else if (!strcmp(value, "merges"))
+	else if (!strcmp(value, "merges") || !strcmp(value, "m"))
 		return REBASE_MERGES;
-	else if (!strcmp(value, "interactive"))
+	else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
 		return REBASE_INTERACTIVE;
 
 	if (fatal)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 68aa5f034..5e501c8b0 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -475,10 +475,22 @@ test_expect_success 'pull.rebase=interactive' '
 	false
 	EOF
 	test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
+	test_when_finished "test_might_fail git rebase --abort" &&
 	test_must_fail git pull --rebase=interactive . copy &&
 	test "I was here" = "$(cat fake.out)"
 '
 
+test_expect_success 'pull --rebase=i' '
+	write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
+	echo I was here, too >fake.out &&
+	false
+	EOF
+	test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
+	test_when_finished "test_might_fail git rebase --abort" &&
+	test_must_fail git pull --rebase=i . copy &&
+	test "I was here, too" = "$(cat fake.out)"
+'
+
 test_expect_success 'pull.rebase=invalid fails' '
 	git reset --hard before-preserve-rebase &&
 	test_config pull.rebase invalid &&
-- 
gitgitgadget

```

## Junio C Hamano, 2018-08-06 19:59

Subject: Re: [PATCH 1/1] pull --rebase=<type>: allow single-letter abbreviations for the type
Message-ID: <xmqqh8k7nu4l.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqh8k7nu4l.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <d2ba1e6bef9d6d4eabc8eaa60435dcae1105fd07.1533410586.git.gitgitgadget@gmail.com>

```
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Git for Windows' original 4aa8b8c8283 (Teach 'git pull' to handle
> --rebase=interactive, 2011-10-21) had support for the very convenient
> abbreviation
>
> 	git pull --rebase=i
>
> which was later lost when it was ported to the builtin `git pull`, and
> it was not introduced before the patch eventually made it into Git as
> f5eb87b98dd (pull: allow interactive rebase with --rebase=interactive,
> 2016-01-13).
>
> However, it is *really* a useful short hand for the occasional rebasing
> pull on branches that do not usually want to be rebased.
>
> So let's reintroduce this convenience, at long last.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---

Makes sense, whether this patch is adding back what in the past
existed only in the Windows port but lost, and whether the lossage
was long time ago or in just a few releases go, or it is adding a
complete new feature for that matter.  This looks like a good
short-hand.

Will queue.

```

## Johannes Schindelin, 2018-08-07 12:02

Subject: Re: [PATCH 1/1] pull --rebase=<type>: allow single-letter abbreviations for the type
Message-ID: <nycvar.QRO.7.76.6.1808071401540.71@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1808071401540.71%40tvgsbejvaqbjf.bet
In-Reply-To: <xmqqh8k7nu4l.fsf@gitster-ct.c.googlers.com>

```
Hi Junio,

On Mon, 6 Aug 2018, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> 
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > Git for Windows' original 4aa8b8c8283 (Teach 'git pull' to handle
> > --rebase=interactive, 2011-10-21) had support for the very convenient
> > abbreviation
> >
> > 	git pull --rebase=i
> >
> > which was later lost when it was ported to the builtin `git pull`, and
> > it was not introduced before the patch eventually made it into Git as
> > f5eb87b98dd (pull: allow interactive rebase with --rebase=interactive,
> > 2016-01-13).
> >
> > However, it is *really* a useful short hand for the occasional rebasing
> > pull on branches that do not usually want to be rebased.
> >
> > So let's reintroduce this convenience, at long last.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> 
> Makes sense, whether this patch is adding back what in the past
> existed only in the Windows port but lost, and whether the lossage
> was long time ago or in just a few releases go, or it is adding a
> complete new feature for that matter.  This looks like a good
> short-hand.
> 
> Will queue.

Thanks!
Dscho

```

## Ævar Arnfjörð Bjarmason, 2018-08-07 19:28

Subject: Re: [PATCH 1/1] pull --rebase=<type>: allow single-letter abbreviations for the type
Message-ID: <87sh3qrn6d.fsf@evledraar.gmail.com>
URL: https://gitlist.dev/e/87sh3qrn6d.fsf%40evledraar.gmail.com
In-Reply-To: <d2ba1e6bef9d6d4eabc8eaa60435dcae1105fd07.1533410586.git.gitgitgadget@gmail.com>

```

On Sat, Aug 04 2018, Johannes Schindelin via GitGitGadget wrote:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Git for Windows' original 4aa8b8c8283 (Teach 'git pull' to handle
> --rebase=interactive, 2011-10-21) had support for the very convenient
> abbreviation
>
> 	git pull --rebase=i
>
> which was later lost when it was ported to the builtin `git pull`, and
> it was not introduced before the patch eventually made it into Git as
> f5eb87b98dd (pull: allow interactive rebase with --rebase=interactive,
> 2016-01-13).
>
> However, it is *really* a useful short hand for the occasional rebasing
> pull on branches that do not usually want to be rebased.
>
> So let's reintroduce this convenience, at long last.

I agree with the shorthand, but I really think this should be
documented. The amount of people who'll discover this by reading the
code is much smaller than those who might discover it via the docs.

> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  builtin/pull.c  |  6 +++---
>  t/t5520-pull.sh | 12 ++++++++++++
>  2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/pull.c b/builtin/pull.c
> index 4e7893539..53bc5facf 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -48,11 +48,11 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
>  		return REBASE_FALSE;
>  	else if (v > 0)
>  		return REBASE_TRUE;
> -	else if (!strcmp(value, "preserve"))
> +	else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
>  		return REBASE_PRESERVE;
> -	else if (!strcmp(value, "merges"))
> +	else if (!strcmp(value, "merges") || !strcmp(value, "m"))
>  		return REBASE_MERGES;
> -	else if (!strcmp(value, "interactive"))
> +	else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
>  		return REBASE_INTERACTIVE;

Here 3 special cases are added...

>  	if (fatal)
> diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
> index 68aa5f034..5e501c8b0 100755
> --- a/t/t5520-pull.sh
> +++ b/t/t5520-pull.sh
> @@ -475,10 +475,22 @@ test_expect_success 'pull.rebase=interactive' '
>  	false
>  	EOF
>  	test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
> +	test_when_finished "test_might_fail git rebase --abort" &&
>  	test_must_fail git pull --rebase=interactive . copy &&
>  	test "I was here" = "$(cat fake.out)"
>  '
>
> +test_expect_success 'pull --rebase=i' '
> +	write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
> +	echo I was here, too >fake.out &&
> +	false
> +	EOF
> +	test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
> +	test_when_finished "test_might_fail git rebase --abort" &&
> +	test_must_fail git pull --rebase=i . copy &&
> +	test "I was here, too" = "$(cat fake.out)"
> +'
> +
>  test_expect_success 'pull.rebase=invalid fails' '
>  	git reset --hard before-preserve-rebase &&
>  	test_config pull.rebase invalid &&

...but this test is only for 1/3. I haven't run this, but it looks like
the tests will still pass if we remove --rebase=p and --rebase=m.

```

## Junio C Hamano, 2018-08-08 19:51

Subject: Re: [PATCH 1/1] pull --rebase=<type>: allow single-letter abbreviations for the type
Message-ID: <xmqqmutwfxh0.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqmutwfxh0.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <87sh3qrn6d.fsf@evledraar.gmail.com>

```
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>> -	else if (!strcmp(value, "preserve"))
>> +	else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
>>  		return REBASE_PRESERVE;
>> -	else if (!strcmp(value, "merges"))
>> +	else if (!strcmp(value, "merges") || !strcmp(value, "m"))
>>  		return REBASE_MERGES;
>> -	else if (!strcmp(value, "interactive"))
>> +	else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
>>  		return REBASE_INTERACTIVE;
>
> Here 3 special cases are added...
> ...
>> +test_expect_success 'pull --rebase=i' '
>> ...
>> +'
>> +
>>  test_expect_success 'pull.rebase=invalid fails' '
>>  	git reset --hard before-preserve-rebase &&
>>  	test_config pull.rebase invalid &&
>
> ...but this test is only for 1/3. I haven't run this, but it looks like
> the tests will still pass if we remove --rebase=p and --rebase=m.

Good eyes.  It's not like that parsing these three is implemented
with one thing; in other words, it is not hard to break one without
breaking the other two.





```

## Junio C Hamano, 2018-08-08 22:19

Subject: Re: [PATCH 1/1] pull --rebase=<type>: allow single-letter abbreviations for the type
Message-ID: <xmqqk1p0ec2v.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqk1p0ec2v.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <xmqqmutwfxh0.fsf@gitster-ct.c.googlers.com>

```
Junio C Hamano <gitster@pobox.com> writes:

> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>>> -	else if (!strcmp(value, "preserve"))
>>> +	else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
>>>  		return REBASE_PRESERVE;
>>> -	else if (!strcmp(value, "merges"))
>>> +	else if (!strcmp(value, "merges") || !strcmp(value, "m"))
>>>  		return REBASE_MERGES;
>>> -	else if (!strcmp(value, "interactive"))
>>> +	else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
>>>  		return REBASE_INTERACTIVE;
>>
>> Here 3 special cases are added...
>> ...
>>> +test_expect_success 'pull --rebase=i' '
>>> ...
>>> +'
>>> +
>>>  test_expect_success 'pull.rebase=invalid fails' '
>>>  	git reset --hard before-preserve-rebase &&
>>>  	test_config pull.rebase invalid &&
>>
>> ...but this test is only for 1/3. I haven't run this, but it looks like
>> the tests will still pass if we remove --rebase=p and --rebase=m.
>
> Good eyes.  It's not like that parsing these three is implemented
> with one thing; in other words, it is not hard to break one without
> breaking the other two.

Having said that, that can be done as a follow-up "oops, the
original was sloppy" patch.  It's not as bad compared to "oops, the
original was totally borked and here is a fix", so I am OK with that
;-)

```
