Page MenuHomePhabricator

tighten remote URI error handling with idiosyncratic remote names
ClosedPublic

Authored by cburroughs on Dec 28 2016, 10:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 14, 4:23 PM
Unknown Object (File)
Fri, Mar 1, 12:50 PM
Unknown Object (File)
Fri, Mar 1, 2:12 AM
Unknown Object (File)
Feb 21 2024, 9:13 AM
Unknown Object (File)
Feb 3 2024, 1:39 PM
Unknown Object (File)
Feb 3 2024, 1:39 PM
Unknown Object (File)
Feb 3 2024, 1:38 PM
Unknown Object (File)
Feb 3 2024, 1:38 PM
Tokens
"100" token, awarded by cburroughs.

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
Branch
ls_remote (branched from master)
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/repository/api/ArcanistGitAPI.php:548XHP16TODO Comment
Unit
Tests Passed
Build Status
Buildable 15038
Build 19733: Run Core Tests
Build 19732: arc lint + arc unit

Event Timeline

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 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.

u need a real avatar before landing codez

  • breadcrumbs for future explorers
This revision was automatically updated to reflect the committed changes.