Page MenuHomePhabricator

tighten remote URI error handling with idiosyncratic remote names
ClosedPublic

Authored by cburroughs on Dec 28 2016, 10:20 PM.

Details

Summary

git ls-remote has an unusual way to indicate a URL was not
found: echoing back user input

$ git ls-remote --get-url does_not_exist
does_not_exist
$ echo $?
0

getRemoteURI handles checking for remotes other than 'origin', but
the error handling always matched against the string 'origin'
regardless of remote name.

Test Plan

With a git config along the lines of:

[remote "my_special_name"]
        url = ssh://secure@secure.phabricator.com/diffusion/ARC/arcanist.git
        fetch = +refs/heads/*:refs/remotes/my_special_name/*
[branch "master"]
        remote = github
        merge = refs/heads/master
[remote "github"]
         # url = git@github.com:phacility/arcanist.git
         fetch = +refs/heads/*:refs/remotes/github/*

and running in a branch tracking master (github). arc which would
(without this diff) show:

The remote URI for this working copy is "github".

With this diff, arc which correctly shows:

Unable to determine the remote URI for this repository.

When diffing against a tracking branch with a propertly configured
remote (the happy path), arc which still correctly identifies the
remote URI:

The remote URI for this working copy is
"ssh://secure@secure.phabricator.com/diffusion/ARC/arcanist.git".

Diff Detail

Repository
rARC Arcanist
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

cburroughs created this revision.Dec 28 2016, 10:20 PM

It looks like git remote get-url <remote-name> has sane error behavior. Did you happen to dig up any version information on that while figuring this out?

epriestley accepted this revision.Dec 28 2016, 10:33 PM
epriestley added a reviewer: epriestley.

Hrrm, it looks like get-url is fairly recent (September 2015, not sure what release it made it into):

https://github.com/git/git/commit/96f78d39989d1fcf393d7bc42357467dd8cf0f15

Maybe leave a note about it in a comment for the next time someone ends up here (along the lines of "In recent versions of git 'git remote get-url' is available.").

This revision is now accepted and ready to land.Dec 28 2016, 10:33 PM

GitHub's tag list in that URL points towards 2.7.0 in January of 2016.

chad added a subscriber: chad.Dec 28 2016, 10:42 PM

u need a real avatar before landing codez

  • breadcrumbs for future explorers

that is a pro avatar

This revision was automatically updated to reflect the committed changes.