pull --rebase=<type>: allow single-letter abbreviations for the type
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 4 Aug 2018 19:23:09 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Aug 2018 20:04:28 +0000 (13:04 -0700)
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>
builtin/pull.c
t/t5520-pull.sh
index 49cc3beb4c428a4bd0513d922b59465ab0c5c414..5b92aa60c26e7afed69c590f28639cfed675aa94 100644 (file)
@@ -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)
index 59c4b778d3a455b6ef4575a4b07b860d1e84720d..07e4c7f9ab3605c728035a63347cfe5bd79efab0 100755 (executable)
@@ -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 &&