merge: deprecate 'git merge <message> HEAD <commit>' syntax

We had this in "git merge" manual for eternity: 'git merge' <msg> HEAD <commit>... [This] syntax (<msg> `HEAD` <commit>...) is supported for historical reasons. Do not use it from the command line or in new scripts. It is the same as `git merge -m <msg> <commit>...`. With the update to "git merge" to make it understand what is recorded in FETCH_HEAD directly, including Octopus merge cases, we now can rewrite the use of this syntax in "git pull" with a simple "git merge FETCH_HEAD". Also there are quite a few fallouts in the test scripts, and it turns out that "git cvsimport" also uses this old syntax to record a merge. Judging from this result, I would not be surprised if dropping the support of the old syntax broke scripts people have written and been relying on for the past ten years. But at least we can start the deprecation process by throwing a warning message when the syntax is used. With luck, we might be able to drop the support in a few years. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Mar 25, 2015 at 21:58 UTC d45366e8aa922037e7e84c3f35924d2b1399a453
7 files changed +9 -9
builtin/merge.c
+1
@@ -1299,6 +1299,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1299 */
1300 if (!have_message &&
1301 is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
1302 + warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
1303 strbuf_addstr(&merge_msg, argv[0]);
1304 head_arg = argv[1];
1305 argv += 2;
git-cvsimport.perl
+1 -1
@@ -1162,7 +1162,7 @@ if ($orig_branch) {
1162 die "Fast-forward update failed: $?\n" if $?;
1163 }
1164 else {
1165 - system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
1165 + system(qw(git merge -m cvsimport), "$remote/$opt_o");
1166 die "Could not merge $opt_o into the current branch.\n" if $?;
1167 }
1168 } else {
git-pull.sh
+1 -2
@@ -323,7 +323,6 @@ then
323 fi
324 fi
325
326 -merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
326 case "$rebase" in
327 true)
328 eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity"
@@ -334,7 +333,7 @@ true)
333 eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"
334 eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
335 eval="$eval $gpg_sign_args"
337 - eval="$eval \"\$merge_name\" HEAD $merge_head"
336 + eval="$eval FETCH_HEAD"
337 ;;
338 esac
339 eval "exec $eval"
t/t3402-rebase-merge.sh
+1 -1
@@ -47,7 +47,7 @@ test_expect_success setup '
47 '
48
49 test_expect_success 'reference merge' '
50 - git merge -s recursive "reference merge" HEAD master
50 + git merge -s recursive -m "reference merge" master
51 '
52
53 PRE_REBASE=$(git rev-parse test-rebase)
t/t6020-merge-df.sh
+1 -1
@@ -24,7 +24,7 @@ test_expect_success 'prepare repository' '
24 '
25
26 test_expect_success 'Merge with d/f conflicts' '
27 - test_expect_code 1 git merge "merge msg" B master
27 + test_expect_code 1 git merge -m "merge msg" master
28 '
29
30 test_expect_success 'F/D conflict' '
t/t6021-merge-criss-cross.sh
+3 -3
@@ -48,7 +48,7 @@ echo "1
48 " > file &&
49 git commit -m "C3" file &&
50 git branch C3 &&
51 -git merge "pre E3 merge" B A &&
51 +git merge -m "pre E3 merge" A &&
52 echo "1
53 2
54 3 changed in E3, branch B. New file size
@@ -61,7 +61,7 @@ echo "1
61 " > file &&
62 git commit -m "E3" file &&
63 git checkout A &&
64 -git merge "pre D8 merge" A C3 &&
64 +git merge -m "pre D8 merge" C3 &&
65 echo "1
66 2
67 3 changed in C3, branch B
@@ -73,7 +73,7 @@ echo "1
73 9" > file &&
74 git commit -m D8 file'
75
76 -test_expect_success 'Criss-cross merge' 'git merge "final merge" A B'
76 +test_expect_success 'Criss-cross merge' 'git merge -m "final merge" B'
77
78 cat > file-expect <<EOF
79 1
t/t9402-git-cvsserver-refs.sh
+1 -1
@@ -496,7 +496,7 @@ test_expect_success 'check [cvswork3] diff' '
496 '
497
498 test_expect_success 'merge early [cvswork3] b3 with b1' '
499 - ( cd gitwork3 && git merge "message" HEAD b1 ) &&
499 + ( cd gitwork3 && git merge -m "message" b1 ) &&
500 git fetch gitwork3 b3:b3 &&
501 git tag v3merged b3 &&
502 git push --tags gitcvs.git b3:b3