{"thread":{"id":"43607","subject":"[PATCH] merge: allow merging into a yet-to-be-born branch.","startedAt":"2006-11-22T05:24:05Z","lastAt":"2006-11-22T05:24:05Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295934","messageId":"7vlkm4vytm.fsf@assigned-by-dhcp.cox.net","threadId":"43607","inReplyTo":null,"subject":"[PATCH] merge: allow merging into a yet-to-be-born branch.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-22T05:24:05Z","receivedAt":"2006-11-22T05:24:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * This is not useful in a freshly initialized repository, since\n   it would not have any commits that you can use with the\n   command.  But you can push into the repository and then later\n   use the updated branch to merge into your 'master' branch\n   that still does not exist yet.\n\n git-merge.sh |   18 ++++++++++++++++++\n 1 files changed, 18 insertions(+), 0 deletions(-)\n\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 25deb1e..dd4e83d 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -159,6 +159,24 @@ then\n \tshift\n \thead_arg=\"$1\"\n \tshift\n+elif ! git-rev-parse --verify HEAD 2>/dev/null\n+then\n+\t# If the merged head is a valid one there is no reason to\n+\t# forbid \"git merge\" into a branch yet to be born.  We do\n+\t# the same for \"git pull\".\n+\tif test 1 -ne $#\n+\tthen\n+\t\techo >&2 \"Can merge only exactly one commit into empty head\"\n+\t\texit 1\n+\tfi\n+\n+\trh=$(git rev-parse --verify \"$1^0\") ||\n+\t\tdie \"$1 - not something we can merge\"\n+\n+\tgit-update-ref -m \"initial pull\" HEAD \"$rh\" \"\" &&\n+\tgit-read-tree --reset -u HEAD\n+\texit\n+\n else\n \t# We are invoked directly as the first-class UI.\n \thead_arg=HEAD\n-- \n1.4.4.g26805\n\n"}]}