pull --rebase=<type>: allow single-letter abbreviations for the type

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Aug 4, 2018 at 12:23 UTC 46af44b07dd433c073778f0d5ab27d0167dbcec4
2 files changed +15 -3
builtin/pull.c
+3 -3
@@ -48,11 +48,11 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
48 return REBASE_FALSE;
49 else if (v > 0)
50 return REBASE_TRUE;
51 - else if (!strcmp(value, "preserve"))
51 + else if (!strcmp(value, "preserve") || !strcmp(value, "p"))
52 return REBASE_PRESERVE;
53 - else if (!strcmp(value, "merges"))
53 + else if (!strcmp(value, "merges") || !strcmp(value, "m"))
54 return REBASE_MERGES;
55 - else if (!strcmp(value, "interactive"))
55 + else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
56 return REBASE_INTERACTIVE;
57
58 if (fatal)
t/t5520-pull.sh
+12
@@ -475,10 +475,22 @@ test_expect_success 'pull.rebase=interactive' '
475 false
476 EOF
477 test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
478 + test_when_finished "test_might_fail git rebase --abort" &&
479 test_must_fail git pull --rebase=interactive . copy &&
480 test "I was here" = "$(cat fake.out)"
481 '
482
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 +
494 test_expect_success 'pull.rebase=invalid fails' '
495 git reset --hard before-preserve-rebase &&
496 test_config pull.rebase invalid &&