Skip to content

Commit 46af44b

Browse files
dschogitster
authored andcommitted
pull --rebase=<type>: allow single-letter abbreviations for the type
Git for Windows' original 4aa8b8c (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 f5eb87b (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53f9a3e commit 46af44b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

builtin/pull.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
4848
return REBASE_FALSE;
4949
else if (v > 0)
5050
return REBASE_TRUE;
51-
else if (!strcmp(value, "preserve"))
51+
else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
5252
return REBASE_PRESERVE;
53-
else if (!strcmp(value, "merges"))
53+
else if (!strcmp(value, "merges") || !strcmp(value, "m"))
5454
return REBASE_MERGES;
55-
else if (!strcmp(value, "interactive"))
55+
else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
5656
return REBASE_INTERACTIVE;
5757

5858
if (fatal)

t/t5520-pull.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,22 @@ test_expect_success 'pull.rebase=interactive' '
475475
false
476476
EOF
477477
test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
478+
test_when_finished "test_might_fail git rebase --abort" &&
478479
test_must_fail git pull --rebase=interactive . copy &&
479480
test "I was here" = "$(cat fake.out)"
480481
'
481482

483+
test_expect_success 'pull --rebase=i' '
484+
write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
485+
echo I was here, too >fake.out &&
486+
false
487+
EOF
488+
test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
489+
test_when_finished "test_might_fail git rebase --abort" &&
490+
test_must_fail git pull --rebase=i . copy &&
491+
test "I was here, too" = "$(cat fake.out)"
492+
'
493+
482494
test_expect_success 'pull.rebase=invalid fails' '
483495
git reset --hard before-preserve-rebase &&
484496
test_config pull.rebase invalid &&

0 commit comments

Comments
 (0)