]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/merge.c
replace {pre,suf}fixcmp() with {starts,ends}_with()
[thirdparty/git.git] / builtin / merge.c
index 34a6166b520c8ede9973fbf497b21ac6ecb761ad..4941a6c36ab215fdb709ac58a3aea69218025dbb 100644 (file)
@@ -186,33 +186,26 @@ static int option_parse_n(const struct option *opt,
        return 0;
 }
 
-static int option_parse_ff_only(const struct option *opt,
-                         const char *arg, int unset)
-{
-       fast_forward = FF_ONLY;
-       return 0;
-}
-
 static struct option builtin_merge_options[] = {
        { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
                N_("do not show a diffstat at the end of the merge"),
                PARSE_OPT_NOARG, option_parse_n },
-       OPT_BOOLEAN(0, "stat", &show_diffstat,
+       OPT_BOOL(0, "stat", &show_diffstat,
                N_("show a diffstat at the end of the merge")),
-       OPT_BOOLEAN(0, "summary", &show_diffstat, N_("(synonym to --stat)")),
+       OPT_BOOL(0, "summary", &show_diffstat, N_("(synonym to --stat)")),
        { OPTION_INTEGER, 0, "log", &shortlog_len, N_("n"),
          N_("add (at most <n>) entries from shortlog to merge commit message"),
          PARSE_OPT_OPTARG, NULL, DEFAULT_MERGE_LOG_LEN },
-       OPT_BOOLEAN(0, "squash", &squash,
+       OPT_BOOL(0, "squash", &squash,
                N_("create a single commit instead of doing a merge")),
-       OPT_BOOLEAN(0, "commit", &option_commit,
+       OPT_BOOL(0, "commit", &option_commit,
                N_("perform a commit if the merge succeeds (default)")),
        OPT_BOOL('e', "edit", &option_edit,
                N_("edit message before committing")),
        OPT_SET_INT(0, "ff", &fast_forward, N_("allow fast-forward (default)"), FF_ALLOW),
-       { OPTION_CALLBACK, 0, "ff-only", NULL, NULL,
+       { OPTION_SET_INT, 0, "ff-only", &fast_forward, NULL,
                N_("abort if fast-forward is not possible"),
-               PARSE_OPT_NOARG | PARSE_OPT_NONEG, option_parse_ff_only },
+               PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, FF_ONLY },
        OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
        OPT_BOOL(0, "verify-signatures", &verify_signatures,
                N_("Verify that the named commit has a valid GPG signature")),
@@ -224,12 +217,12 @@ static struct option builtin_merge_options[] = {
                N_("merge commit message (for a non-fast-forward merge)"),
                option_parse_message),
        OPT__VERBOSITY(&verbosity),
-       OPT_BOOLEAN(0, "abort", &abort_current_merge,
+       OPT_BOOL(0, "abort", &abort_current_merge,
                N_("abort the current in-progress merge")),
        OPT_SET_INT(0, "progress", &show_progress, N_("force progress reporting"), 1),
        { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key id"),
          N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
-       OPT_BOOLEAN(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
+       OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
        OPT_END()
 };
 
@@ -453,17 +446,17 @@ static void merge_name(const char *remote, struct strbuf *msg)
                die(_("'%s' does not point to a commit"), remote);
 
        if (dwim_ref(remote, strlen(remote), branch_head, &found_ref) > 0) {
-               if (!prefixcmp(found_ref, "refs/heads/")) {
+               if (starts_with(found_ref, "refs/heads/")) {
                        strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
                }
-               if (!prefixcmp(found_ref, "refs/tags/")) {
+               if (starts_with(found_ref, "refs/tags/")) {
                        strbuf_addf(msg, "%s\t\ttag '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
                }
-               if (!prefixcmp(found_ref, "refs/remotes/")) {
+               if (starts_with(found_ref, "refs/remotes/")) {
                        strbuf_addf(msg, "%s\t\tremote-tracking branch '%s' of .\n",
                                    sha1_to_hex(branch_head), remote);
                        goto cleanup;
@@ -577,8 +570,8 @@ static int git_merge_config(const char *k, const char *v, void *cb)
 {
        int status;
 
-       if (branch && !prefixcmp(k, "branch.") &&
-               !prefixcmp(k + 7, branch) &&
+       if (branch && starts_with(k, "branch.") &&
+               starts_with(k + 7, branch) &&
                !strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
                free(branch_mergeoptions);
                branch_mergeoptions = xstrdup(v);
@@ -1113,7 +1106,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
         * current branch.
         */
        branch = branch_to_free = resolve_refdup("HEAD", head_sha1, 0, &flag);
-       if (branch && !prefixcmp(branch, "refs/heads/"))
+       if (branch && starts_with(branch, "refs/heads/"))
                branch += 11;
        if (!branch || is_null_sha1(head_sha1))
                head_commit = NULL;
@@ -1193,7 +1186,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
         * This could be traditional "merge <msg> HEAD <commit>..."  and
         * the way we can tell it is to see if the second token is HEAD,
         * but some people might have misused the interface and used a
-        * committish that is the same as HEAD there instead.
+        * commit-ish that is the same as HEAD there instead.
         * Traditional format never would have "-m" so it is an
         * additional safety measure to check for it.
         */