Re: [PATCH v2] Fix fetch/pull when run without --update-head-ok
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Oct 14, 2008, 16:15 UTC
- Message-ID
- <alpine.DEB.1.00.0810141808020.22125@pacific.mpi-cbg.de.mpi-cbg.de>
- In-Reply-To
- <20081014150227.GC4856@spearce.org>
Hi,
On Tue, 14 Oct 2008, Shawn O. Pearce wrote:
Show 16 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > > On Mon, 13 Oct 2008, Daniel Barkalow wrote: > > > > > On Mon, 13 Oct 2008, Johannes Schindelin wrote: > > > > > > > I actually understand now why the tests started failing: the change from > > > > resolve_ref() to get_branch() as requested by Daniel are at fault: > > > > get_branch() does not check if the branch has an initial commit. > > > > So, my vote is to revert back to resolve_ref(), even if it needs more > > lines. > > Yes, I agree, resolve_ref() is the best thing to be using here, > even if it is more code. get_branch() validates the commit and we > don't want that. We really just want to know if the current branch > is going to be updated, we don't care to what/why.
Actually, get_branch() does _not_ validate. Which is why it thinks that the current branch is "master" even if there is no commit yet.
OTOH, resolve_ref() reads the SHA-1 of the ref, which fails in the case that there has not been any commit yet.
Still, I think that it would be nice to allow "git pull origin master:master" in a freshly initied non-bare repository, so I like resolve_ref() better.
Ciao, Dscho