Skip to content

Commit d45366e

Browse files
committed
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 <[email protected]>
1 parent 74e8bc5 commit d45366e

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

builtin/merge.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
12991299
*/
13001300
if (!have_message &&
13011301
is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
1302+
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
13021303
strbuf_addstr(&merge_msg, argv[0]);
13031304
head_arg = argv[1];
13041305
argv += 2;

git-cvsimport.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ sub commit {
11621162
die "Fast-forward update failed: $?\n" if $?;
11631163
}
11641164
else {
1165-
system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
1165+
system(qw(git merge -m cvsimport), "$remote/$opt_o");
11661166
die "Could not merge $opt_o into the current branch.\n" if $?;
11671167
}
11681168
} else {

git-pull.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ then
323323
fi
324324
fi
325325

326-
merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
327326
case "$rebase" in
328327
true)
329328
eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity"
@@ -334,7 +333,7 @@ true)
334333
eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"
335334
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
336335
eval="$eval $gpg_sign_args"
337-
eval="$eval \"\$merge_name\" HEAD $merge_head"
336+
eval="$eval FETCH_HEAD"
338337
;;
339338
esac
340339
eval "exec $eval"

t/t3402-rebase-merge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_expect_success setup '
4747
'
4848

4949
test_expect_success 'reference merge' '
50-
git merge -s recursive "reference merge" HEAD master
50+
git merge -s recursive -m "reference merge" master
5151
'
5252

5353
PRE_REBASE=$(git rev-parse test-rebase)

t/t6020-merge-df.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test_expect_success 'prepare repository' '
2424
'
2525

2626
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
2828
'
2929

3030
test_expect_success 'F/D conflict' '

t/t6021-merge-criss-cross.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ echo "1
4848
" > file &&
4949
git commit -m "C3" file &&
5050
git branch C3 &&
51-
git merge "pre E3 merge" B A &&
51+
git merge -m "pre E3 merge" A &&
5252
echo "1
5353
2
5454
3 changed in E3, branch B. New file size
@@ -61,7 +61,7 @@ echo "1
6161
" > file &&
6262
git commit -m "E3" file &&
6363
git checkout A &&
64-
git merge "pre D8 merge" A C3 &&
64+
git merge -m "pre D8 merge" C3 &&
6565
echo "1
6666
2
6767
3 changed in C3, branch B
@@ -73,7 +73,7 @@ echo "1
7373
9" > file &&
7474
git commit -m D8 file'
7575

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'
7777

7878
cat > file-expect <<EOF
7979
1

t/t9402-git-cvsserver-refs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ test_expect_success 'check [cvswork3] diff' '
496496
'
497497

498498
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 ) &&
500500
git fetch gitwork3 b3:b3 &&
501501
git tag v3merged b3 &&
502502
git push --tags gitcvs.git b3:b3

0 commit comments

Comments
 (0)