mirror of
https://github.com/git/git.git
synced 2024-10-30 13:57:54 +01:00
merge: do not check argc to determine number of remote heads
To reject merging multiple commits into an unborn branch, we check argc, thinking that collect_parents() that reads the remaining command line arguments from <argc, argv> will give us the same number of commits as its input, i.e. argc. Because what we really care about is the number of commits, let the function run and then make sure it returns only one commit instead. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
1faac1cedc
commit
eaa4e59c85
1 changed files with 2 additions and 3 deletions
|
@ -1185,9 +1185,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
||||||
* to forbid "git merge" into a branch yet to be born.
|
* to forbid "git merge" into a branch yet to be born.
|
||||||
* We do the same for "git pull".
|
* We do the same for "git pull".
|
||||||
*/
|
*/
|
||||||
if (argc != 1)
|
|
||||||
die(_("Can merge only exactly one commit into "
|
|
||||||
"empty head"));
|
|
||||||
if (squash)
|
if (squash)
|
||||||
die(_("Squash commit into empty head not supported yet"));
|
die(_("Squash commit into empty head not supported yet"));
|
||||||
if (fast_forward == FF_NO)
|
if (fast_forward == FF_NO)
|
||||||
|
@ -1197,6 +1194,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
||||||
remote_head = remoteheads->item;
|
remote_head = remoteheads->item;
|
||||||
if (!remote_head)
|
if (!remote_head)
|
||||||
die(_("%s - not something we can merge"), argv[0]);
|
die(_("%s - not something we can merge"), argv[0]);
|
||||||
|
if (remoteheads->next)
|
||||||
|
die(_("Can merge only exactly one commit into empty head"));
|
||||||
read_empty(remote_head->object.sha1, 0);
|
read_empty(remote_head->object.sha1, 0);
|
||||||
update_ref("initial pull", "HEAD", remote_head->object.sha1,
|
update_ref("initial pull", "HEAD", remote_head->object.sha1,
|
||||||
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
|
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
|
||||||
|
|
Loading…
Reference in a new issue