Merge branch 'cp/merge-continue'
authorJunio C Hamano <gitster@pobox.com>
Tue, 27 Dec 2016 08:11:41 +0000 (00:11 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Dec 2016 08:11:41 +0000 (00:11 -0800)
"git merge --continue" has been added as a synonym to "git commit"
to conclude a merge that has stopped due to conflicts.

* cp/merge-continue:
merge: mark usage error strings for translation
merge: ensure '--abort' option takes no arguments
completion: add --continue option for merge
merge: add '--continue' option as a synonym for 'git commit'

1  2 
builtin/merge.c
contrib/completion/git-completion.bash
diff --combined builtin/merge.c
index 0070bf255612ea9d4826720df7a77dd8ccb762e8,599d25c4ccb71c9d0c2b246d5c8c35b88dc73a5e..a96d4fb501bf1441b52a313313b8c04f3187e4d9
@@@ -46,6 -46,7 +46,7 @@@ static const char * const builtin_merge
        N_("git merge [<options>] [<commit>...]"),
        N_("git merge [<options>] <msg> HEAD <commit>"),
        N_("git merge --abort"),
+       N_("git merge --continue"),
        NULL
  };
  
@@@ -65,6 -66,7 +66,7 @@@ static int option_renormalize
  static int verbosity;
  static int allow_rerere_auto;
  static int abort_current_merge;
+ static int continue_current_merge;
  static int allow_unrelated_histories;
  static int show_progress = -1;
  static int default_to_upstream = 1;
@@@ -223,6 -225,8 +225,8 @@@ static struct option builtin_merge_opti
        OPT__VERBOSITY(&verbosity),
        OPT_BOOL(0, "abort", &abort_current_merge,
                N_("abort the current in-progress merge")),
+       OPT_BOOL(0, "continue", &continue_current_merge,
+               N_("continue the current in-progress merge")),
        OPT_BOOL(0, "allow-unrelated-histories", &allow_unrelated_histories,
                 N_("allow merging unrelated histories")),
        OPT_SET_INT(0, "progress", &show_progress, N_("force progress reporting"), 1),
@@@ -634,7 -638,7 +638,7 @@@ static int try_merge_strategy(const cha
  {
        static struct lock_file lock;
  
 -      hold_locked_index(&lock, 1);
 +      hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
        refresh_cache(REFRESH_QUIET);
        if (active_cache_changed &&
            write_locked_index(&the_index, &lock, COMMIT_LOCK))
                for (j = common; j; j = j->next)
                        commit_list_insert(j->item, &reversed);
  
 -              hold_locked_index(&lock, 1);
 +              hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
                clean = merge_recursive(&o, head,
                                remoteheads->item, reversed, &result);
                if (clean < 0)
@@@ -781,7 -785,7 +785,7 @@@ static int merge_trivial(struct commit 
        struct commit_list *parents, **pptr = &parents;
        static struct lock_file lock;
  
 -      hold_locked_index(&lock, 1);
 +      hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
        refresh_cache(REFRESH_QUIET);
        if (active_cache_changed &&
            write_locked_index(&the_index, &lock, COMMIT_LOCK))
@@@ -1125,6 -1129,7 +1129,7 @@@ int cmd_merge(int argc, const char **ar
        const char *best_strategy = NULL, *wt_strategy = NULL;
        struct commit_list *remoteheads, *p;
        void *branch_to_free;
+       int orig_argc = argc;
  
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage_with_options(builtin_merge_usage, builtin_merge_options);
                int nargc = 2;
                const char *nargv[] = {"reset", "--merge", NULL};
  
+               if (orig_argc != 2)
+                       usage_msg_opt(_("--abort expects no arguments"),
+                             builtin_merge_usage, builtin_merge_options);
                if (!file_exists(git_path_merge_head()))
                        die(_("There is no merge to abort (MERGE_HEAD missing)."));
  
                goto done;
        }
  
+       if (continue_current_merge) {
+               int nargc = 1;
+               const char *nargv[] = {"commit", NULL};
+               if (orig_argc != 2)
+                       usage_msg_opt(_("--continue expects no arguments"),
+                             builtin_merge_usage, builtin_merge_options);
+               if (!file_exists(git_path_merge_head()))
+                       die(_("There is no merge in progress (MERGE_HEAD missing)."));
+               /* Invoke 'git commit' */
+               ret = cmd_commit(nargc, nargv, prefix);
+               goto done;
+       }
        if (read_cache_unmerged())
                die_resolve_conflict("merge");
  
index 78fe5b7f5c793c864614a6f1738be207eecee2c8,1f97ffae199232fcbf372d028c4802ace91d638b..6721ff80fb1324ec1cf450f7b69cbf8266880035
@@@ -1552,7 -1552,7 +1552,7 @@@ _git_merge (
        case "$cur" in
        --*)
                __gitcomp "$__git_merge_options
-                       --rerere-autoupdate --no-rerere-autoupdate --abort"
+                       --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
                return
        esac
        __gitcomp_nl "$(__git_refs)"
@@@ -1734,10 -1734,10 +1734,10 @@@ _git_rebase (
  {
        local dir="$(__gitdir)"
        if [ -f "$dir"/rebase-merge/interactive ]; then
 -              __gitcomp "--continue --skip --abort --edit-todo"
 +              __gitcomp "--continue --skip --abort --quit --edit-todo"
                return
        elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
 -              __gitcomp "--continue --skip --abort"
 +              __gitcomp "--continue --skip --abort --quit"
                return
        fi
        __git_complete_strategy && return