Skip to content

Commit

Permalink
merge: deprecate 'git merge <message> HEAD <commit>' syntax
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Apr 29, 2015
1 parent 74e8bc5 commit d45366e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
*/
if (!have_message &&
is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
strbuf_addstr(&merge_msg, argv[0]);
head_arg = argv[1];
argv += 2;
Expand Down
2 changes: 1 addition & 1 deletion git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ sub commit {
die "Fast-forward update failed: $?\n" if $?;
}
else {
system(qw(git merge cvsimport HEAD), "$remote/$opt_o");
system(qw(git merge -m cvsimport), "$remote/$opt_o");
die "Could not merge $opt_o into the current branch.\n" if $?;
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions git-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ then
fi
fi

merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
case "$rebase" in
true)
eval="git-rebase $diffstat $strategy_args $merge_args $rebase_args $verbosity"
Expand All @@ -334,7 +333,7 @@ true)
eval="git-merge $diffstat $no_commit $verify_signatures $edit $squash $no_ff $ff_only"
eval="$eval $log_arg $strategy_args $merge_args $verbosity $progress"
eval="$eval $gpg_sign_args"
eval="$eval \"\$merge_name\" HEAD $merge_head"
eval="$eval FETCH_HEAD"
;;
esac
eval "exec $eval"
2 changes: 1 addition & 1 deletion t/t3402-rebase-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test_expect_success setup '
'

test_expect_success 'reference merge' '
git merge -s recursive "reference merge" HEAD master
git merge -s recursive -m "reference merge" master
'

PRE_REBASE=$(git rev-parse test-rebase)
Expand Down
2 changes: 1 addition & 1 deletion t/t6020-merge-df.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test_expect_success 'prepare repository' '
'

test_expect_success 'Merge with d/f conflicts' '
test_expect_code 1 git merge "merge msg" B master
test_expect_code 1 git merge -m "merge msg" master
'

test_expect_success 'F/D conflict' '
Expand Down
6 changes: 3 additions & 3 deletions t/t6021-merge-criss-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ echo "1
" > file &&
git commit -m "C3" file &&
git branch C3 &&
git merge "pre E3 merge" B A &&
git merge -m "pre E3 merge" A &&
echo "1
2
3 changed in E3, branch B. New file size
Expand All @@ -61,7 +61,7 @@ echo "1
" > file &&
git commit -m "E3" file &&
git checkout A &&
git merge "pre D8 merge" A C3 &&
git merge -m "pre D8 merge" C3 &&
echo "1
2
3 changed in C3, branch B
Expand All @@ -73,7 +73,7 @@ echo "1
9" > file &&
git commit -m D8 file'

test_expect_success 'Criss-cross merge' 'git merge "final merge" A B'
test_expect_success 'Criss-cross merge' 'git merge -m "final merge" B'

cat > file-expect <<EOF
1
Expand Down
2 changes: 1 addition & 1 deletion t/t9402-git-cvsserver-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ test_expect_success 'check [cvswork3] diff' '
'

test_expect_success 'merge early [cvswork3] b3 with b1' '
( cd gitwork3 && git merge "message" HEAD b1 ) &&
( cd gitwork3 && git merge -m "message" b1 ) &&
git fetch gitwork3 b3:b3 &&
git tag v3merged b3 &&
git push --tags gitcvs.git b3:b3
Expand Down

0 comments on commit d45366e

Please sign in to comment.