Merge branch 'js/pull-rebase-type-shorthand'
authorJunio C Hamano <gitster@pobox.com>
Fri, 17 Aug 2018 20:09:59 +0000 (13:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Aug 2018 20:09:59 +0000 (13:09 -0700)
"git pull --rebase=interactive" learned "i" as a short-hand for
"interactive".

* js/pull-rebase-type-shorthand:
pull --rebase=<type>: allow single-letter abbreviations for the type

1  2 
builtin/pull.c
t/t5520-pull.sh
diff --combined builtin/pull.c
index 4e789353922340c3d0727a2e2c3e60e5a9936ee5,5b92aa60c26e7afed69c590f28639cfed675aa94..53bc5facfdabd05934a351091f2040744b2575ca
@@@ -48,11 -48,11 +48,11 @@@ static enum rebase_type parse_config_re
                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)
@@@ -356,7 -356,7 +356,7 @@@ static int git_pull_config(const char *
   */
  static void get_merge_heads(struct oid_array *merge_heads)
  {
 -      const char *filename = git_path_fetch_head();
 +      const char *filename = git_path_fetch_head(the_repository);
        FILE *fp;
        struct strbuf sb = STRBUF_INIT;
        struct object_id oid;
@@@ -684,7 -684,7 +684,7 @@@ static const char *get_tracking_branch(
        const char *spec_src;
        const char *merge_branch;
  
 -      refspec_item_init(&spec, refspec, REFSPEC_FETCH);
 +      refspec_item_init_or_die(&spec, refspec, REFSPEC_FETCH);
        spec_src = spec.src;
        if (!*spec_src || !strcmp(spec_src, "HEAD"))
                spec_src = "HEAD";
@@@ -765,13 -765,10 +765,13 @@@ static int get_octopus_merge_base(struc
  {
        struct commit_list *revs = NULL, *result;
  
 -      commit_list_insert(lookup_commit_reference(curr_head), &revs);
 -      commit_list_insert(lookup_commit_reference(merge_head), &revs);
 +      commit_list_insert(lookup_commit_reference(the_repository, curr_head),
 +                         &revs);
 +      commit_list_insert(lookup_commit_reference(the_repository, merge_head),
 +                         &revs);
        if (!is_null_oid(fork_point))
 -              commit_list_insert(lookup_commit_reference(fork_point), &revs);
 +              commit_list_insert(lookup_commit_reference(the_repository, fork_point),
 +                                 &revs);
  
        result = get_octopus_merge_bases(revs);
        free_commit_list(revs);
@@@ -867,7 -864,7 +867,7 @@@ int cmd_pull(int argc, const char **arg
        if (read_cache_unmerged())
                die_resolve_conflict("pull");
  
 -      if (file_exists(git_path_merge_head()))
 +      if (file_exists(git_path_merge_head(the_repository)))
                die_conclude_merge();
  
        if (get_oid("HEAD", &orig_head))
                        struct commit_list *list = NULL;
                        struct commit *merge_head, *head;
  
 -                      head = lookup_commit_reference(&orig_head);
 +                      head = lookup_commit_reference(the_repository,
 +                                                     &orig_head);
                        commit_list_insert(head, &list);
 -                      merge_head = lookup_commit_reference(&merge_heads.oid[0]);
 +                      merge_head = lookup_commit_reference(the_repository,
 +                                                           &merge_heads.oid[0]);
                        if (is_descendant_of(merge_head, list)) {
                                /* we can fast-forward this without invoking rebase */
                                opt_ff = "--ff-only";
diff --combined t/t5520-pull.sh
index 68aa5f0340132e8d3fabfd85aa70f1cdfe755cf3,07e4c7f9ab3605c728035a63347cfe5bd79efab0..5e501c8b08868b17478b8baa91db2cd129cd1c67
@@@ -475,10 -475,22 +475,22 @@@ test_expect_success 'pull.rebase=intera
        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 &&
@@@ -618,18 -630,6 +630,18 @@@ test_expect_success 'pull --rebase fail
        )
  '
  
 +test_expect_success 'pull --rebase fails on corrupt HEAD' '
 +      test_when_finished "rm -rf corrupt" &&
 +      git init corrupt &&
 +      (
 +              cd corrupt &&
 +              test_commit one &&
 +              obj=$(git rev-parse --verify HEAD | sed "s#^..#&/#") &&
 +              rm -f .git/objects/$obj &&
 +              test_must_fail git pull --rebase
 +      )
 +'
 +
  test_expect_success 'setup for detecting upstreamed changes' '
        mkdir src &&
        (cd src &&