Skip to content

Commit

Permalink
merge: allow merging into a yet-to-be-born branch.
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Nov 22, 2006
1 parent 17bcdad commit 8092c7f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions git-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8092c7f

Please sign in to comment.