git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Try harder to find a remote when on a detached HEAD or non-tracking branch.

From
Marc Branchaud <marcnarc@xiplink.com>
Date
Jun 18, 2012, 21:40 UTC
Message-ID
<4FDFA030.7080408@xiplink.com>
In-Reply-To
<7vaa004j9f.fsf@alter.siamese.dyndns.org>
On 12-06-18 01:33 PM, Junio C Hamano wrote:
Show 18 quoted lines
> marcnarc@xiplink.com writes:
> 
>> From: Marc Branchaud <marcnarc@xiplink.com>
>>
>> get_default_remote() tries to use the checked-out branch's 'remote' config
>> value to figure out the remote's name.  This fails if there is no currently
>> checked-out branch (i.e. HEAD is detached) or if the checked-out branch
>> doesn't track a remote.  In these cases and the function would just fall
>> back to "origin".
>>
>> Instead, let's use the first remote listed in the configuration, and fall
>> back to "origin" only if we don't find any configured remotes.
> 
> I admit that I wouldn't do anything that relies on any remote to be
> used while on detached head myself, so in that sense I am a biased
> audience, but guessing (or not guessing and blindly assuming
> 'origin') feels wrong, and trying even harder to come up with an
> even wilder guess feels even more wrong.

OK, but what would be right? AFAIK git doesn't have any real way of designating an official default remote. It seems to me that the first one in the config is actually better than just using "origin". At least, that remote seems very likely to be the one used when the repo was cloned.

> Shouldn't we be erroring out instead?

That would be bad for our situation. As I said, our automated build system uses detached HEADs a lot. Erroring-out in this case would break us. It's really only the near-ubiquity of the name "origin" that has kept things working so far.

But we finally ran into a situation where someone used "git clone -o", and that seems to have broken relative-path submodules in some situations. (I would not be at all surprised if "git clone -o" breaks an assortment of other features, too. I think there are a few places in the code where "origin" is presumed to be a valid remote name, and also the one the user wants to use.)

		M.
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 20 in “Try harder to find a remote when on a detached HEAD or non-tracking branch.”
  1. Try harder to find a remote when on a detached HEAD or non-tracking branch.marcnarc@xiplink.com, Jun 18, 2012
  2. Junio C HamanoJun 18, 2012
  3. Marc BranchaudJun 18, 2012
  4. Junio C HamanoJun 18, 2012
  5. Marc BranchaudJun 19, 2012
  6. Junio C HamanoJun 19, 2012
  7. Heiko VoigtJun 19, 2012
  8. Marc BranchaudJun 19, 2012
  9. Heiko VoigtJun 20, 2012
  10. Jeff KingJun 19, 2012
  11. Junio C HamanoJun 19, 2012
  12. Marc BranchaudJun 19, 2012
  13. Jeff KingJun 19, 2012
  14. Junio C HamanoJun 19, 2012
  15. Jeff KingJun 19, 2012
  16. Junio C HamanoJun 19, 2012
  17. Jens LehmannJun 19, 2012
  18. Marc BranchaudJun 19, 2012
  19. Phil HordJun 20, 2012
  20. Arnaud LacombeJun 18, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.