From: Junio C Hamano Date: Tue, 1 Dec 2009 20:47:01 +0000 (-0800) Subject: Merge branch 'jc/deprecate-old-syntax-from-merge' X-Git-Tag: v1.6.6-rc1~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/36a83f375bc247a09f46de0445a138d5e6de8a4f?hp=-c Merge branch 'jc/deprecate-old-syntax-from-merge' * jc/deprecate-old-syntax-from-merge: git-merge: a deprecation notice of the ancient command line syntax --- 36a83f375bc247a09f46de0445a138d5e6de8a4f diff --combined builtin-merge.c index fc7066e3c7,6bf841e78c..21045776b3 --- a/builtin-merge.c +++ b/builtin-merge.c @@@ -43,7 -43,6 +43,7 @@@ static const char * const builtin_merge static int show_diffstat = 1, option_log, squash; static int option_commit = 1, allow_fast_forward = 1; +static int fast_forward_only; static int allow_trivial = 1, have_message; static struct strbuf merge_msg; static struct commit_list *remoteheads; @@@ -107,8 -106,8 +107,8 @@@ static struct strategy *get_strategy(co found = 1; if (!found) add_cmdname(¬_strategies, ent->name, ent->len); - exclude_cmds(&main_cmds, ¬_strategies); } + exclude_cmds(&main_cmds, ¬_strategies); } if (!is_in_cmdlist(&main_cmds, name) && !is_in_cmdlist(&other_cmds, name)) { fprintf(stderr, "Could not find merge strategy '%s'.\n", name); @@@ -167,9 -166,7 +167,9 @@@ static struct option builtin_merge_opti OPT_BOOLEAN(0, "commit", &option_commit, "perform a commit if the merge succeeds (default)"), OPT_BOOLEAN(0, "ff", &allow_fast_forward, - "allow fast forward (default)"), + "allow fast-forward (default)"), + OPT_BOOLEAN(0, "ff-only", &fast_forward_only, + "abort if fast-forward is not possible"), OPT_CALLBACK('s', "strategy", &use_strategies, "strategy", "merge strategy to use", option_parse_strategy), OPT_CALLBACK('m', "message", &merge_msg, "message", @@@ -267,7 -264,6 +267,7 @@@ static void squash_message(void struct strbuf out = STRBUF_INIT; struct commit_list *j; int fd; + struct pretty_print_context ctx = {0}; printf("Squash commit -- not updating HEAD\n"); fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666); @@@ -289,15 -285,13 +289,15 @@@ if (prepare_revision_walk(&rev)) die("revision walk setup failed"); + ctx.abbrev = rev.abbrev; + ctx.date_mode = rev.date_mode; + strbuf_addstr(&out, "Squashed commit of the following:\n"); while ((commit = get_revision(&rev)) != NULL) { strbuf_addch(&out, '\n'); strbuf_addf(&out, "commit %s\n", sha1_to_hex(commit->object.sha1)); - pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev, - NULL, NULL, rev.date_mode, 0); + pretty_print_commit(rev.commit_format, commit, &out, &ctx); } if (write(fd, out.buf, out.len) < 0) die_errno("Writing SQUASH_MSG"); @@@ -656,7 -650,6 +656,7 @@@ static int checkout_fast_forward(unsign opts.verbose_update = 1; opts.merge = 1; opts.fn = twoway_merge; + opts.msgs = get_porcelain_error_msgs(); trees[nr_trees] = parse_tree_indirect(head); if (!trees[nr_trees++]) @@@ -796,6 -789,11 +796,11 @@@ static int suggest_conflicts(void return 1; } + static const char deprecation_warning[] = + "'git merge HEAD ' is deprecated. Please update\n" + "your script to use 'git merge -m ' instead.\n" + "In future versions of git, this syntax will be removed."; + static struct commit *is_old_style_invocation(int argc, const char **argv) { struct commit *second_token = NULL; @@@ -809,6 -807,7 +814,7 @@@ die("'%s' is not a commit", argv[1]); if (hashcmp(second_token->object.sha1, head)) return NULL; + warning(deprecation_warning); } return second_token; } @@@ -847,6 -846,7 +853,6 @@@ int cmd_merge(int argc, const char **ar const char *best_strategy = NULL, *wt_strategy = NULL; struct commit_list **remotes = &remoteheads; - setup_work_tree(); if (file_exists(git_path("MERGE_HEAD"))) die("You have not concluded your merge. (MERGE_HEAD exists)"); if (read_cache_unmerged()) @@@ -880,9 -880,6 +886,9 @@@ option_commit = 0; } + if (!allow_fast_forward && fast_forward_only) + die("You cannot combine --no-ff with --ff-only."); + if (!argc) usage_with_options(builtin_merge_usage, builtin_merge_options); @@@ -1022,7 -1019,7 +1028,7 @@@ hex, find_unique_abbrev(remoteheads->item->object.sha1, DEFAULT_ABBREV)); - strbuf_addstr(&msg, "Fast forward"); + strbuf_addstr(&msg, "Fast-forward"); if (have_message) strbuf_addstr(&msg, " (no commit created; -m option ignored)"); @@@ -1040,16 -1037,16 +1046,16 @@@ } else if (!remoteheads->next && common->next) ; /* - * We are not doing octopus and not fast forward. Need + * We are not doing octopus and not fast-forward. Need * a real merge. */ else if (!remoteheads->next && !common->next && option_commit) { /* - * We are not doing octopus, not fast forward, and have + * We are not doing octopus, not fast-forward, and have * only one common. */ refresh_cache(REFRESH_QUIET); - if (allow_trivial) { + if (allow_trivial && !fast_forward_only) { /* See if it is really trivial. */ git_committer_info(IDENT_ERROR_ON_NO_NAME); printf("Trying really trivial in-index merge...\n"); @@@ -1088,9 -1085,6 +1094,9 @@@ } } + if (fast_forward_only) + die("Not possible to fast-forward, aborting."); + /* We are going to make a new commit. */ git_committer_info(IDENT_ERROR_ON_NO_NAME);