@matheusbsbs / matheus-bagliano / commits / 8092c7f6af
Fork 0

merge: allow merging into a yet-to-be-born branch.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 21, 2006 at 21:13 UTC 8092c7f6af044836abf83ed26d542327a4b95c08
1 file changed +18
git-merge.sh
+18
@@ -159,6 +159,24 @@ then
159 shift
160 head_arg="$1"
161 shift
162 +elif ! git-rev-parse --verify HEAD 2>/dev/null
163 +then
164 + # If the merged head is a valid one there is no reason to
165 + # forbid "git merge" into a branch yet to be born. We do
166 + # the same for "git pull".
167 + if test 1 -ne $#
168 + then
169 + echo >&2 "Can merge only exactly one commit into empty head"
170 + exit 1
171 + fi
172 +
173 + rh=$(git rev-parse --verify "$1^0") ||
174 + die "$1 - not something we can merge"
175 +
176 + git-update-ref -m "initial pull" HEAD "$rh" "" &&
177 + git-read-tree --reset -u HEAD
178 + exit
179 +
180 else
181 # We are invoked directly as the first-class UI.
182 head_arg=HEAD