summaryrefslogtreecommitdiffstats
path: root/git_config.py
Commit message (Collapse)AuthorAgeFilesLines
* implement optional 'pushurl' in the manifest fileSteve Rae2016-09-201-0/+5
| | | | | | | | Allow the 'remote' element in the manifest file to define an optional 'pushurl' attribute which is passed into the .git/config file. Change-Id: If342d299d371374aedc4440645798888869c9714 Signed-off-by: Steve Rae <steve.rae@raedomain.com>
* Merge "Repo: improve error detection for new ssh connections"David Pursehouse2016-09-201-1/+5
|\
| * Repo: improve error detection for new ssh connectionsTimo Lotterbach2016-08-301-1/+5
| | | | | | | | | | | | | | | | this check can only detect errors that happen within 1 sec after launching ssh. But this is typically enough to catch configuration issues like 'connection refused' or 'authentication failed'. Change-Id: I00b6f62d4c2889b1faa6c820e49a198554c92795
* | Repo: fall back to http, if ssh connection fails for http reposTimo Lotterbach2016-08-301-1/+4
|/ | | | | | | | | | | | | | if a gerrit server has ssh and https access enabled, but user access (for some users) is limited to https, 'repo upload' command will fail for them. Gerrit returns a ssh configuration (gerrit/ssh_info), that does not work for users limited to https. With this patch repo will test, if the returned ssh configuration from gerrit/ssh_info is working. if not, it will fall back to https for upload. Change-Id: If98f472e994f350bf71f35610cd649b163f1ab33
* Support smart-sync through persistent-http[s]Dan Willemsen2015-08-191-0/+39
| | | | | | | Use the same cookies and proxy that git traffic goes through for persistent-http[s] to support authentication for smart-sync. Change-Id: I20f4a281c259053a5a4fdbc48b1bca48e781c692
* git_config: fix _SaveJson typoAnthony King2015-06-041-1/+1
| | | | Change-Id: I35ca2b3733e6d1508669f9a6690c6645c582912e
* git_config: add support for remote '.'v1.12.19Yann Droneaud2015-03-061-1/+1
| | | | | | | | | | | | | | | | | | | As a fix for issue #149, this patch add support for the remote '.' (local). As an alias for the local repository, remote '.' is lacking a fetch = config in .git/config. Without such refspec, repo info --overview is not able to process a local tracking branch. v2: Check for name == '.' before checking if merge starts with refs/, since the case where it's not is invalid. Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> Signed-off-by: Filipe Brandenburger <filbranden@google.com> Change-Id: I8c8fd8602cd68baecb530301ae41d37d751ec85d
* Support persistent-http(s) review urlsConley Owens2014-10-231-0/+2
| | | | Change-Id: I8e0065685c968dfa9dc26bcdb6ee2fa14019c509
* Support specifying non-HEADS refs as upstreamNasser Grainawi2014-10-091-2/+4
| | | | | | | | | While not typical, some users might have an upstream that isn't in the usual refs/heads/* namespace. There's no reason not to use those refs as the value for the upstream attribute, so support doing so. Change-Id: I5b119f1135c3268c20e7c4084682e860d3ee1fb1
* Don't open non-binary files as binaryChirayu Desai2014-08-191-1/+1
| | | | | | * Don't pen the git config file, and the git ".lock" file as binary. Change-Id: I7b3939658456f2fd0a0500443cdd8d1ee1a4459d
* Merge "Fix UrlInsteadOf to handle multiple strings"Conley Owens2014-06-301-3/+3
|\
| * Fix UrlInsteadOf to handle multiple stringsDan Willemsen2014-03-061-3/+3
| | | | | | | | | | | | | | For complex .gitconfig url rewrites, multiple insteadOf lines may be used for a url. Search all of them for the right rewrite. Change-Id: If5e9ecd054e86226924b0baf513801cd57c389cd
* | Use JSON instead of pickleAnthony King2014-05-071-32/+22
|/ | | | | | | Use JSON as it is shown to be much faster than pickle. Also clean up the loading and saving functions. Change-Id: I45b3dee7b4d59a1c0e0d38d4a83b543ac5839390
* Stop appending 'p/' to review urlsConley Owens2014-02-041-1/+1
| | | | | | | Gerrit no longer requires 'p/', and this causes unexpected behavior. In this change we stop appending 'p/' to the urls. Change-Id: I72c13bf838f4112086141959fb1af249f9213ce6
* Changes to support sso: repositories for uploadSteve Pucci2014-01-311-1/+4
| | | | Change-Id: Iddf90d52f700a1f6462abe76d4f4a367ebb6d603
* Fix some python3 encoding issuesChirayu Desai2013-11-211-2/+2
| | | | | | * Add .decode('utf-8') where needed * Add 'b' to `open` where needed, and remove where unnecessary Change-Id: I0f03ecf9ed1a78e3b2f15f9469deb9aaab698657
* Assume http upload if ssh_info cannot be parsedConley Owens2013-09-271-7/+4
| | | | | | | | | | | | When uploading a change for review, we sometimes request /ssh_info to get the correct port number for uploading via ssh (regardless of whether or not we intend to upload over ssh). If we have trouble accessing /ssh_info (for authentication reasons, etc), we now press on under the assumption that we will upload via http instead of aborting. Change-Id: Ica6bbeac1279e89424a903529649b7f4af0b6937
* Handle HTTPException when attempting to get ssh_infoDavid Pursehouse2013-05-251-0/+6
| | | | | | | | | | | The call to `urlopen` can raise `HTTPException`, but this is not caught which results in a python Traceback. Add handling of the exception. Because `HTTPException` and its derived classes do not have any message, print the name of the exception in the error message instead. Change-Id: Ic90fb4cc0e92702375cd976d4a03876c8ce8bffc
* Move Python version checking to a separate moduleDavid Pursehouse2013-05-231-5/+4
| | | | | | | | | | | | | | | | | Add a new module with methods for checking the Python version. Instead of handling Python3 imports with try...except blocks, first check the python version and then import the relevant modules. This makes the code a bit cleaner and will result in less diff when/if we remove support for Python < 3 later. Use the same mechanism to handle `input` vs. `raw_input` and add suppression of pylint warnings caused by redefinition of the built-in method `input`. Change-Id: Ia403e525b88d77640a741ac50382146e7d635924 Also-by: Chirayu Desai <cdesai@cyanogenmod.org> Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
* Some fixes for supporting python3Chirayu Desai2013-04-181-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix imports. * Use python3 syntax. * Wrap map() calls with list(). * Use list() only wherever needed. (Thanks Conley!) * Fix dictionary iteration methods (s/iteritems/items/). * Make use of sorted() in appropriate places * Use iterators directly in the loop. * Don't use .keys() wherever it isn't needed. * Use sys.maxsize instead of sys.maxint TODO: * Make repo work fully with python3. :) Some of this was done by the '2to3' tool [1], by applying the needed fixes in a way that doesn't break compatibility with python2. Links: [1]: http://docs.python.org/2/library/2to3.html Change-Id: Ibdf3bf9a530d716db905733cb9bfef83a48820f7 Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
* Tidy up code formatting a bit moreDavid Pursehouse2012-11-141-1/+1
| | | | | | | | | | | | Enable the following Pylint warnings: C0322: Operator not preceded by a space C0323: Operator not followed by a space C0324: Comma not followed by a space And make the necessary fixes. Change-Id: I74d74283ad5138cbaf28d492b18614eb355ff9fe
* Fix inconsistent indentationDavid Pursehouse2012-11-141-3/+3
| | | | | | | | | | The repo coding style is to indent at 2 characters, but there are many places where this is not followed. Enable pylint warning "W0311: Bad indentation" and make sure all indentation is at multiples of 2 characters. Change-Id: I68f0f64470789ce2429ab11104d15d380a63e6a8
* Change print statements to work in python3Sarah Owens2012-11-131-3/+3
| | | | | | This is part of a series of changes to introduce Python3 support. Change-Id: I373be5de7141aa127d7debdbce1df39148dbec32
* Merge "Change usages of xrange() to range()"Conley Owens2012-11-121-1/+1
|\
| * Change usages of xrange() to range()Sarah Owens2012-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In Python3, range() creates a generator rather than a list. None of the parameters in the ranges changed looked large enough to create an impact in memory in Python2. Note: the only use of range() was for iteration and did not need to be changed. This is part of a series of changes to introduce Python3 support. Change-Id: I50b665f9296ea160a5076c71f36a65f76e47029f
* | Fix pylint warning W0108: Lambda may not be necessaryDavid Pursehouse2012-11-071-2/+2
|/ | | | | | Remove unnecessary usage of lambda. Change-Id: I06d41933057d60d15d307ee800cca052a44754c6
* Use python3 urllib when urllib2 not availableSarah Owens2012-10-311-4/+15
| | | | | | This is part of a series of changes to introduce Python3 support. Change-Id: I605b145791053c1f2d7bf3c907c5a68649b21d12
* Even more coding style cleanupDavid Pursehouse2012-10-301-2/+3
| | | | | | | | | | | Fixing some more pylint warnings: W1401: Anomalous backslash in string W0623: Redefining name 'name' from outer scope W0702: No exception type(s) specified E0102: name: function already defined line n Change-Id: I5afcdb4771ce210390a79981937806e30900a93c
* Use modern Python exception syntaxSarah Owens2012-10-231-3/+3
| | | | | | | | | | | "except Exception as e" instead of "except Exception, e" This is part of a transition to supporting Python 3. Python >= 2.6 support "as" syntax. Note: this removes Python 2.5 support. Change-Id: I309599f3981bba2b46111c43102bee38ff132803
* Coding style cleanupDavid Pursehouse2012-10-091-16/+16
| | | | | | | | | | | | | | | Fix the following issues reported by pylint: C0321: More than one statement on a single line W0622: Redefining built-in 'name' W0612: Unused variable 'name' W0613: Unused argument 'name' W0102: Dangerous default value 'value' as argument W0105: String statement has no effect Also fixed a few cases of inconsistent indentation. Change-Id: Ie0db839e7c57d576cff12d8c055fe87030d00744
* Permit - in URL schemes for special URLsShawn O. Pearce2012-03-141-1/+1
| | | | | | | | | Clients might be using their own special git-remote-* helper that has a hypen in its name. Permit - in the scheme part of the URL when trying to decide if it is an SSH URL and assume it is *not* SSH if the URL matches "foo-bar://" style. Change-Id: I7ba2d810a614f6e605a441d5972902c4a14e73fd
* upload: Support uploading to Gerrit over https://v1.7.8.2Shawn O. Pearce2012-01-111-48/+27
| | | | | | | | If SSH is not available, Gerrit returns NOT_AVAILABLE to the /ssh_info query made by repo upload. In this case fallback to the /p/$PROJECT URL that Gerrit also exports and use that for uploads. Change-Id: I1e3e39ab709ecc0a692614a41a42446426f39c08
* upload: Honor REPO_HOST_PORT_INFO environment variablev1.7.7.3Shawn O. Pearce2011-10-111-0/+10
| | | | | | | | REPO_HOST_PORT_INFO can be set to 'host:port' and be used instead of the review URL given in the manifest. Change-Id: I440bdecb2c2249fe5285ec5d0c28a937b4053450 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Fix AttributeError: 'HTTPError' object has no attribute 'reason'v1.7.7.2Shawn O. Pearce2011-10-111-6/+5
| | | | | | | | | | Not every version of urllib2 supplies a reason object on the HTTPError exception that it throws from urlopen(). Work around this by using str(e) instead and hope the string formatting includes sufficient information. Change-Id: I0f4586dba0aa7152691b2371627c951f91fdfc8d Signed-off-by: Shawn O. Pearce <sop@google.com>
* sync: Support downloading bundle to initialize repositoryv1.7.7Shawn O. Pearce2011-09-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | An HTTP (or HTTPS) based remote server may now offer a 'clone.bundle' file in each repository's Git directory. Over an http:// or https:// remote repo will first ask for '$URL/clone.bundle', and if present download this to bootstrap the local client, rather than relying on the native Git transport to initialize the new repository. Bundles may be hosted elsewhere. The client automatically follows a HTTP 302 redirect to acquire the bundle file. This allows servers to direct clients to cached copies residing on content delivery networks, where the bundle may be closer to the end-user. Bundle downloads are resumeable from where they last left off, allowing clients to initialize large repositories even when the connection gets interrupted. If a bundle does not exist for a repository (a HTTP 404 response code is returned for '$URL/clone.bundle'), the native Git transport is used instead. If the client is performing a shallow sync, the bundle transport is not used, as there is no way to embed shallow data into the bundle. Change-Id: I05dad17792fd6fd20635a0f71589566e557cc743 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Add support for url.*.insteadofShawn O. Pearce2011-09-191-0/+9
| | | | | | | | | | | | Teach repo how to resolve URLs using the url.insteadof feature that C Git natively uses during clone, fetch or push. This will later allow repo to resolve a URL before accessing it directly. We do not want to pre-resolve things and store the resolved URL into individual projects, as this makes it impossible for the user to undo the insteadof mapping at a later date. Change-Id: I0f62e811197c53fbc8a8be424e3cabf4ed07b4cb Signed-off-by: Shawn O. Pearce <sop@google.com>
* Honor http_proxy variable globallyShawn O. Pearce2011-09-111-6/+0
| | | | | | | | If the http_proxy environment variable was set, honor it during the entire repo session for any Python created HTTP connections. Change-Id: Ib4ae833cb2cdd47ab0126949f6b399d2c142887d Signed-off-by: Shawn O. Pearce <sop@google.com>
* Honor 'http_proxy' environment variableAnatol Pomozov2011-07-201-0/+6
| | | | | | | | | | | 'repo upload' makes http request using urllib2 python library. Unfortunately this library does not work (by default) in case if the user behind a proxy. This change adds proxy handler in case if 'http_proxy' environment variable is set. Change-Id: Ic4176ad733fc21bd5b59661b3eacc2f0a7c3c1ff
* upload: Catch and cleanly report connectivity errorsShawn O. Pearce2011-01-091-3/+7
| | | | | | | | | | | Instead of giving a Python backtrace when there is a connectivity problem during repo upload, report that we cannot access the host, and why, with a halfway decent error message. Bug: REPO-45 Change-Id: I9a45b387e86e48073a2d99bd6d594c1a7d6d99d4 Signed-off-by: Shawn O. Pearce <sop@google.com> (cherry picked from commit d2dfac81ad6a060179b4b2289060af2dc7a5cdfd)
* Fixed race condition in 'repo sync -jN' that would open multiple masters.v1.7.2Doug Anderson2010-12-211-60/+88
| | | | | | | | This fixes the SSH Control Masters to be managed in a thread-safe fashion. This is important because "repo sync -jN" uses threads to sync more than one repository at the same time. The problem didn't show up earlier because it was masked if all of the threads tried to connect to the same host that was used on the "repo init" line.
* Only delete corrupt pickle config files if they existUlrik Sjölin2010-10-291-2/+4
| | | | | | | | | os.remove() raises OSError if the file being removed doesn't exist. Check before calling to ensure we don't raise a useless exception on an already deleted file. Change-Id: I44c1c7dd97a47fcab8afb6c18fdf179158b6dab7 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Check for existing SSH ControlMasterDoug Anderson2010-10-291-12/+41
| | | | | | | | | Be more thorough about checking for an existing ssh master by running a test command first, and only opening up a new master if the test fails to connect. Change-Id: I56fe8e7b4dbc123675b7f259e81d359ed0cd55cf Signed-off-by: Shawn O. Pearce <sop@google.com>
* upload: Allow review.HOST.username to override emailv1.6.10Shawn O. Pearce2010-07-151-1/+4
| | | | | | | | | | Some users might need to use a different login name than the local part of their email address for their Gerrit Code Review user account. Allow it to be overridden with the review.HOST.username configuration variable. Change-Id: I714469142ac7feadf09fee9c26680c0e09076b75 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Do not invoke ssh with -p argument when no port has been specified.Josh Guilfoyle2010-06-081-5/+12
| | | | | | | | | This change allows local SSH configuration to choose the port number to use when not explicitly set in the manifest. (cherry picked from commit 4c0f67046543c7c6ab24175e143001f14b76ea01) Change-Id: Ibea99cfe46b6a2cc27f754cc3944a2fe10f6fda4
* sync: kill git fetch process before SSH control master processv1.6.9.6Shawn O. Pearce2010-05-111-1/+6
| | | | | | | | | | | | | | | | If the SSH control master process is killed while an active git fetch is using its network socket, the underlying SSH client may not realize the connection was broken. This can lead to both the client and the server waiting indefinitely for network messages which will never be sent. Work around the problem by keeping track of any processes that use the tunnels we establish. If we are about to kill any of the SSH control masters that we started, ensure the clients using them are successfully killed first. Change-Id: Ida6c124dcb0c6a26bf7dd69cba2fbdc2ecd5b2fc Signed-off-by: Shawn O. Pearce <sop@google.com>
* Rename _ssh_sock() to fix code style issue.Nico Sallembien2010-04-271-3/+3
| | | | | Since _ssh_sock is imported out of the git_command module, the leading underscore should be removed from the function name.
* Honor url.insteadOf when setting up SSH control master connectionv1.6.8.10Ulrik Sjolin2010-01-041-1/+23
| | | | | | | | | | Repo can now properly handle url.insteadOf sections in the user's ~/.gitconfig file. This means that a user can now enjoy the master-ssh functionality even if he/she uses insteadOf's in ~/.gitconfig to rewrite git:// URLs to ssh:// style URLs. Change-Id: Ic0f04a9c57206a7b89eb0f10bf188c4c483debe3 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Fix error parsing a non-existant configuration filev1.6.8.7Shawn O. Pearce2009-07-021-2/+4
| | | | | | | | If a file (e.g. ~/.gitconfig) does not exist, we get None here rather than a string. NoneType lacks rstrip() so we cannot strip it. Signed-off-by: Shawn O. Pearce <sop@google.com>
* git_config: handle configuration entries with no valuesDavid Aguilar2009-06-291-8/+13
| | | | | | | | | A git-config entry with no value was preventing repo from initializing. This modifies _ReadGit() to handle config entries with empty values. Signed-off-by: David Aguilar <davvid@gmail.com> Reported-by: Josh Guilfoyle <jasta00@gmail.com>
* Fix invalid use of try-catchShawn O. Pearce2009-06-161-1/+1
| | | | | | Its try-except in Python. Signed-off-by: Shawn O. Pearce <sop@google.com>