From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [PATCH] merge: allow merging into a yet-to-be-born branch.
Date: Tue, 21 Nov 2006 21:24:05 -0800 [thread overview]
Message-ID: <7vlkm4vytm.fsf@assigned-by-dhcp.cox.net> (raw)
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
* This is not useful in a freshly initialized repository, since
it would not have any commits that you can use with the
command. But you can push into the repository and then later
use the updated branch to merge into your 'master' branch
that still does not exist yet.
git-merge.sh | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/git-merge.sh b/git-merge.sh
index 25deb1e..dd4e83d 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -159,6 +159,24 @@ then
shift
head_arg="$1"
shift
+elif ! git-rev-parse --verify HEAD 2>/dev/null
+then
+ # If the merged head is a valid one there is no reason to
+ # forbid "git merge" into a branch yet to be born. We do
+ # the same for "git pull".
+ if test 1 -ne $#
+ then
+ echo >&2 "Can merge only exactly one commit into empty head"
+ exit 1
+ fi
+
+ rh=$(git rev-parse --verify "$1^0") ||
+ die "$1 - not something we can merge"
+
+ git-update-ref -m "initial pull" HEAD "$rh" "" &&
+ git-read-tree --reset -u HEAD
+ exit
+
else
# We are invoked directly as the first-class UI.
head_arg=HEAD
--
1.4.4.g26805
reply other threads:[~2006-11-22 5:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vlkm4vytm.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox