Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] How to determine remote HEAD from advertised refs?

On Wed, Mar 30, 2011 at 08:21, Lay, Stefan <stefan.lay@xxxxxxx> wrote:
> Is there a way to find out the branch the HEAD points to at a remote
> repository?
>
> The method OperationResult.getAdvertisedRef returns a sha1 for the parameter
> “HEAD”
> but not the branch HEAD points to in the remote repository.
>
> In EGit we try to find a branch which points to the same commit and use this
> as a base
> for the local branch to create and checkout after clone.
>
> In the JGit CloneCommand however there is no such logic and as a result the
> HEAD is detached
> after clone (see bugs 339354, 339254).
>
> The logic implemented in EGit is not nice because it may result in the wrong
> branch if more
> than one branches point to the same commit.

This is the only valid logic right now. The Git network protocol does
not expose what HEAD points to, so C Git guesses by using the logic
that EGit is also using. Sorry, that's the best you can do.

-- 
Shawn.


Back to the top