Re: Cleaning up git user-interface warts
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Nov 16, 2006, 17:57 UTC
- Message-ID
- <Pine.LNX.4.64.0611160932340.3349@woody.osdl.org>
- In-Reply-To
- <Pine.LNX.4.64.0611160904010.3349@woody.osdl.org>
On Thu, 16 Nov 2006, Linus Torvalds wrote:
> > (And the real reason for that is simple: "git pull" simply wants to have > something to _start_ with. It's not hugely fundamental, it's just how it > was written).
Here's a very lightly tested patch that allows you to use "git pull" to populate an empty repository.
I'm not at all sure this is necessarily the nicest way to do it, but it's fairly straightforward.
Junio, what do you think?
Linus
---
diff --git a/git-pull.sh b/git-pull.sh index ed04e7d..7e5cee2 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -44,10 +44,10 @@ do shift done -orig_head=$(git-rev-parse --verify HEAD) || die "Pulling into a black hole?" +orig_head=$(git-rev-parse --verify HEAD 2> /dev/null) git-fetch --update-head-ok --reflog-action=pull "$@" || exit 1 -curr_head=$(git-rev-parse --verify HEAD) +curr_head=$(git-rev-parse --verify HEAD 2> /dev/null) if test "$curr_head" != "$orig_head" then # The fetch involved updating the current branch. @@ -80,6 +80,11 @@ case "$merge_head" in exit 0 ;; ?*' '?*) + if test -z "$orig_head" + then + echo >&2 "Cannot merge multiple branches into empty head" + exit 1 + fi var=`git-repo-config --get pull.octopus` if test -n "$var" then @@ -95,6 +100,12 @@ case "$merge_head" in ;; esac +if test -z "$orig_head" +then + git-update-ref -m "initial pull" HEAD $merge_head "" || exit 1 + exit +fi + case "$strategy_args" in '')