diff options
author | Junio C Hamano <junkio@cox.net> | 2006-11-21 21:13:28 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-11-21 21:18:07 -0800 |
commit | 8092c7f6af044836abf83ed26d542327a4b95c08 (patch) | |
tree | 6be9f73608c437fc976e4806c272c2eb8e6607ec | |
parent | 17bcdad3b7baa3b12c662663372f1e3cd560dd8e (diff) | |
download | git-8092c7f6af044836abf83ed26d542327a4b95c08.tar.gz git-8092c7f6af044836abf83ed26d542327a4b95c08.tar.xz |
merge: allow merging into a yet-to-be-born branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-x | git-merge.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/git-merge.sh b/git-merge.sh index 25deb1e86..dd4e83ded 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 |