src/remote.c


Log

Author Commit Date CI Message
Carlos Martín Nieto a68e217f 2014-11-02T21:57:14 remote: unify the creation code The create function with default refspec is the same as the one with a custom refspec, but it has the default refspec, so we can create the one on top of the other.
Pierre-Olivier Latour 64bcf567 2014-10-26T10:30:05 Fixed potential crash with uninitialized variables
Edward Thomson 5b0c6306 2014-10-26T22:38:30 Remove unused warning on non-win32
Edward Thomson cdd71711 2014-10-13T14:34:32 Clean up some memory leaks
Carlos Martín Nieto 46c8f7f8 2014-10-24T16:25:59 remote: accept a repo and name for renaming Remote objects are not meant to be changed from under the user. We did this in rename, but only the name and left the refspecs, such that a save would save the wrong refspecs (and a fetch and anything else would use the wrong refspecs). Instead, let's simply take a name and not change any loaded remote from under the user.
Edward Thomson 12f32d91 2014-10-14T16:31:55 Remote paths: canonicalize UNC paths on Win32 Git for Windows will handle UNC paths only when in forward-slash format, eg "//server/path". When given a UNC path as a remote, rewrite standard format ("\\server\path") into this ridiculous format.
Edward Thomson a6ed1fcb 2014-10-10T12:21:28 Merge pull request #2593 from libgit2/cmn/remote-delete-name remote: accept a repository and remote name for deletion
Carlos Martín Nieto 2139c9b7 2014-10-10T17:50:28 Merge pull request #2542 from linquize/fetch-head Do not error out when fetching from second remote
Arthur Schreiber 8e398e4c 2014-10-10T13:17:53 Treat an empty list of refspecs the same as a NULL value.
Carlos Martín Nieto eecc1772 2014-10-09T17:02:11 Fix an uninitialized variable
Carlos Martín Nieto 262eec23 2014-09-30T16:07:30 remote: accept a repository and remote name for deletion We don't need the remote loaded, and the function extracted both of these from the git_remote in order to do its work, so let's remote a step and not ask for the loaded remote at all. This fixes #2390.
Carlos Martín Nieto c5837cad 2014-07-04T09:03:33 remote: implement opportunistic remote-tracking branch updates When a list of refspecs is passed to fetch (what git would consider refspec passed on the command-line), we not only need to perform the updates described in that refspec, but also update the remote-tracking branch of the fetched remote heads according to the remote's configured refspecs. These "fetches" are not however to be written to FETCH_HEAD as they would be duplicate data, and it's not what the user asked for.
Carlos Martín Nieto 2cdd5c57 2014-07-03T07:56:31 remote: store passive refspecs The configured/base fetch refspecs need to be taken into account in order to implement opportunistic remote-tracking branch updates. DWIM them and store them in the struct, but don't do anything with them yet.
Carlos Martín Nieto c300d84a 2014-07-03T07:54:26 remote: don't DWIM refspecs unnecessarily We can only DWIM when we've connected to the remote and have the list of the remote's references. Adding or setting the refspecs should not trigger an attempt to DWIM the refspecs as we typically cannot do it, and even if we did, we would not use them for the current fetch.
Carlos Martín Nieto 3f894205 2014-06-06T15:01:45 remote: allow overriding the refspecs for download and fetch With opportunistic ref updates, git has introduced the concept of having base refspecs *and* refspecs that are active for a particular fetch. Let's start by letting the user override the refspecs for download.
Carlos Martín Nieto 0fef3899 2014-09-16T01:25:53 Merge remote-tracking branch 'upstream/master' into cmn/host-cert-info
Carlos Martín Nieto 41698f22 2014-09-11T10:04:05 net: remove support for outright ignoring certificates This option make it easy to ignore anything about the server we're connecting to, which is bad security practice. This was necessary as we didn't use to expose detailed information about the certificate, but now that we do, we should get rid of this. If the user wants to ignore everything, they can still provide a callback which ignores all the information passed.
Carlos Martín Nieto 9b940586 2014-07-04T12:45:43 Provide a callback for certificate validation If the certificate validation fails (or always in the case of ssh), let the user decide whether to allow the connection. The data structure passed to the user is the native certificate information from the underlying implementation, namely OpenSSL or WinHTTP.
Vicent Marti a7fcac13 2014-09-15T20:26:12 Merge pull request #2554 from linquize/fetch-head-tag When auto follow tags, FETCH_HEAD should list only newly followed tags
Linquize d908351a 2014-09-05T22:31:53 When auto follow tags, FETCH_HEAD should list only newly followed tags
Linquize f49819aa 2014-08-31T17:38:38 When updating FETCH_HEAD, do not treat it as error if the remote of current branch is from another remote
Carlos Martín Nieto 0cdaa376 2014-08-10T17:50:46 remote: short-circuit the default branch check if there is none If we do not have a HEAD ref in the heads, we already know there is no default branch. Return immedately.
Carlos Martín Nieto 38952604 2014-07-14T20:29:53 remote: restrict default branch to branches namespace
Jacques Germishuys dc8adda4 2014-08-15T22:51:19 git_remote_ls() should return an error if the transport is not available
Philip Kelley 1697cd6f 2014-06-25T13:20:27 Improvements to git_transport extensibility git_remote_set_transport now takes a transport factory rather than a transport git_clone_options now allows the caller to specify a remote creation callback
Carlos Martín Nieto 231f350d 2014-06-06T22:55:34 remote: don't free the remote on delete This was a bad idea. Don't free except in the free function.
Carlos Martín Nieto d1544564 2014-06-06T22:38:26 remote: handle symrefs when renaming A symref inside the namespace gets renamed, we should make it point to the target's new name. This is for the origin/HEAD -> origin/master type of situations.
Carlos Martín Nieto 72bca13e 2014-06-06T16:33:54 remote: return problem refspecs instead of using a callback There is no reason why we need to use a callback here. A string array fits better with the usage, as this is not an event and we don't need anything from the user.
Carlos Martín Nieto 61dcfe14 2014-06-06T15:57:37 remote: make sure the name stays valid on rename We must make sure that the name pointer remains valid, so make sure to allocate the new one before freeing the old one and swap them so the user never sees an invalid pointer.
Carlos Martín Nieto 5a49ff9f 2014-06-06T15:54:42 remote: remove rename code for anonymous remotes We don't allow renames of anonymous remotes, so there's no need to handle them. A remote is always associated with a repository, so there's no need to check for that.
Carlos Martín Nieto a52ab4b8 2014-06-06T01:09:49 remote: tighten up reference renaming Tighten up which references we consider for renaming so we don't try to rename unrelated ones and end up with unexplained references. If there is a reference on the target namespace, git overwrites it, so let's do the same.
Vicent Marti bccb36eb 2014-06-03T17:25:59 Merge pull request #2389 from arthurschreiber/arthur/set-error-when-no-remote-found Remote: Set an error when a remote cannot be found.
Carlos Martín Nieto 8a9419aa 2014-06-01T02:16:07 remote: build up the list of refs to remove When removing the remote-tracking branches, build up the list and remove in two steps, working around an issue with the iterator. Removing while we're iterating over the refs can cause us to miss references.
Arthur Schreiber d723dbed 2014-05-30T19:26:49 Remote: Set an error when a remote cannot be found. Inside `git_remote_load`, the calls to `get_optional_config` use `giterr_clear` to unset any errors that are set due to missing config keys. If neither a fetch nor a push url config was found for a remote, we should set an error again.
Carlos Martín Nieto d22db24f 2014-05-21T09:32:35 remote: add api to guess the remote's default branch If the remote supports the symref protocol extension, then we return that, otherwise we guess with git's rules.
Vicent Marti 228272ef 2014-05-16T11:56:37 Merge pull request #2313 from libgit2/cmn/remote-delete Remote deletion
Carlos Martín Nieto ec8a949a 2014-04-30T09:20:03 remote: remove remote-tracking branches on delete When we delete a remote, we also need to go through its fetch refspecs and remove the references they create locally.
Russell Belfer d2c4d1c6 2014-05-12T10:04:52 Merge pull request #2188 from libgit2/cmn/config-snapshot Configuration snapshotting
Carlos Martín Nieto ac99d86b 2014-05-07T11:34:32 repository: introduce a convenience config snapshot method Accessing the repository's config and immediately taking a snapshot of it is a common operation, so let's provide a convenience function for it.
Russell Belfer bc91347b 2014-04-30T11:16:31 Fix remaining init_options inconsistencies There were a couple of "init_opts()" functions a few more cases of structure initialization that I somehow missed.
Jacques Germishuys 183aa4f8 2014-04-30T17:46:53 Check for NULL before passing it to vsnprintf
Carlos Martín Nieto 5cdac19c 2014-04-30T08:29:14 remote: move branch upstream deletion to use an iterator This should make it more readable and allocate a bunch fewer strings.
nulltoken 40e48ea4 2013-11-15T15:36:37 remote: Introduce git_remote_delete()
Vicent Marti 8443ed6c 2014-04-25T02:10:19 Merge pull request #2284 from jacquesg/push-progress-callback Fire progress and update tips callbacks also for pushes.
Carlos Martín Nieto 2efd7df6 2014-04-19T15:34:12 remote: provide read access to the callback structure This should make it easier for bindings to dynamically override their own callbacks.
Jacques Germishuys 98020d3a 2014-04-21T10:55:37 Rename progress callback to sideband_progress
Carlos Martín Nieto 29c4cb09 2014-03-15T03:53:36 Use config snapshotting This way we can assume we have a consistent view of the config situation when we're looking up remote, branch, pack-objects, etc.
Vicent Marti 923c8400 2014-04-04T14:24:08 Merge pull request #2215 from libgit2/rb/submodule-cache-fixes Improve submodule cache management
Carlos Martín Nieto 67d4997a 2014-04-02T18:44:01 remote: mark branch for-merge even if we're unborn When the current branch is unborn, git will still mark the current branch's upstream for-merge if there is an upstream configuration. The only non-constrived case is cloning from an empty repository which then gains history. origin's master should be marked for-merge. In order to do this, we cannot use the high-level wrappers that expect a reference, as we may not have one. Move over to the internal ones that expect a reference name, which we do have.
Russell Belfer 8286300a 2013-12-18T11:48:57 Fix git_submodule_sync and add new config helper This fixes `git_submodule_sync` to correctly update the remote URL of the default branch of the submodule along with the URL in the parent repository config (i.e. match core Git's behavior). Also move some useful helper logic from the submodule code into a shared config API `git_config__update_entry` that can either set or delete an entry with constraints like not overwriting or not creating a new entry. I used that helper to update a couple other places in the code.
Carlos Martín Nieto fd536d29 2014-03-26T11:15:57 remote: rename inmemory to anonymous and swap url and fetch order The order in this function is the opposite to what create_with_fetchspec() has, so change this one, as url-then-refspec is what git does. As we need to break compilation and the swap doesn't do that, let's take this opportunity to rename in-memory remotes to anonymous as that's really what sets them apart.
Matthew Bowen b9f81997 2014-03-05T21:49:23 Added function-based initializers for every options struct. The basic structure of each function is courtesy of arrbee.
Brian Lambert 06a8f5c3 2014-03-05T00:00:41 Fixed missing error check on call to git_remote_download in git_remote_fetch. Moved error check to statement following git_remote_disconnect so that the disconnect happens regardless of the result of the download call.
Ben Straub db55bb73 2014-02-06T11:18:10 Correct default reflog message for git_remote_fetch
Ben Straub c3ab1e5a 2014-02-04T20:38:13 Add reflog parameters to remote apis Also added a test for git_remote_fetch.
Ben Straub ccf6ce5c 2014-01-28T11:30:36 Ensure renaming a reference updates the reflog
Carlos Martín Nieto bf522e08 2014-01-26T16:59:36 refspec: move to git_buf for outputting strings
Arthur Schreiber 991b2840 2014-01-26T19:35:02 Make sure git_remote_dup copies a remote's refspecs correctly.
Arthur Schreiber 11f6ad5f 2014-01-15T21:15:34 Add some missing const declarations.
Carlos Martín Nieto 0b28217b 2014-01-15T12:51:31 refs: remove the _with_log differentiation Any well-behaved program should write a descriptive message to the reflog whenever it updates a reference. Let's make this more prominent by removing the version without the reflog parameters.
Arthur Schreiber 99dcb218 2014-01-14T21:08:20 We don't need memset here.
Arthur Schreiber 616cd137 2014-01-14T21:08:09 Don't duplicate state that's only used when fetching.
Arthur Schreiber 40ef47dd 2014-01-14T21:03:01 Add `git_remote_dup`.
Russell Belfer 9cfce273 2013-12-12T12:11:38 Cleanups, renames, and leak fixes This renames git_vector_free_all to the better git_vector_free_deep and also contains a couple of memory leak fixes based on valgrind checks. The fixes are specifically: failure to free global dir path variables when not compiled with threading on and failure to free filters from the filter registry that had not be initialized fully.
Russell Belfer 26c1cb91 2013-12-09T09:44:03 One more rename/cleanup for callback err functions
Russell Belfer c7b3e1b3 2013-12-06T15:42:20 Some callback error check style cleanups I find this easier to read...
Russell Belfer 25e0b157 2013-12-06T15:07:57 Remove converting user error to GIT_EUSER This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
Russell Belfer fcd324c6 2013-12-06T15:04:31 Add git_vector_free_all There are a lot of places that we call git__free on each item in a vector and then call git_vector_free on the vector itself. This just wraps that up into one convenient helper function.
Russell Belfer dab89f9b 2013-12-04T21:22:57 Further EUSER and error propagation fixes This continues auditing all the places where GIT_EUSER is being returned and making sure to clear any existing error using the new giterr_user_cancel helper. As a result, places that relied on intercepting GIT_EUSER but having the old error preserved also needed to be cleaned up to correctly stash and then retrieve the actual error. Additionally, as I encountered places where error codes were not being propagated correctly, I tried to fix them up. A number of those fixes are included in the this commit as well.
Russell Belfer 96869a4e 2013-12-03T16:45:39 Improve GIT_EUSER handling This adds giterr_user_cancel to return GIT_EUSER and clear any error message that is sitting around. As a result of using that in places, we need to be more thorough with capturing errors that happen inside a callback when used internally. To help with that, this also adds giterr_capture and giterr_restore so that when we internally use a foreach-type function that clears errors and converts them to GIT_EUSER, it is easier to restore not just the return value, but the actual error message text.
Russell Belfer 9f77b3f6 2013-11-25T14:21:34 Add config read fns with controlled error behavior This adds `git_config__lookup_entry` which will look up a key in a config and return either the entry or NULL if the key was not present. Optionally, it can either suppress all errors or can return them (although not finding the key is not an error for this function). Unlike other accessors, this does not normalize the config key string, so it must only be used when the key is known to be in normalized form (i.e. all lower-case before the first dot and after the last dot, with no invalid characters). This also adds three high-level helper functions to look up config values with no errors and a fallback value. The three functions are for string, bool, and int values, and will resort to the fallback value for any error that arises. They are: * `git_config__get_string_force` * `git_config__get_bool_force` * `git_config__get_int_force` None of them normalize the config `key` either, so they can only be used for internal cases where the key is known to be in normal format.
Vicent Martí 7135e77a 2013-11-19T03:13:23 Merge pull request #1967 from victorgp/cleaning-code-minor-change Cleaning code, removing unused variables
Victor Garcia 10b6678f 2013-11-19T11:57:32 cleaning code, removing unused variables
Russell Belfer 8f2a3d62 2013-11-18T12:14:50 Fix warnings
Edward Thomson 80fc7d6b 2013-11-13T16:46:45 Propagate auth error codes as GIT_EUSER in winhttp
Vicent Martí 7b947bf5 2013-11-14T07:21:47 Merge pull request #1951 from victorgp/create-remote-plus-fetch Allowing create remotes with custom fetch spec
Carlos Martín Nieto 877cde76 2013-11-02T01:10:21 remote: let's at least pretend to have some memory safety Copy the pointers into temporary vectors instead of assigning them tot he same array so we don't mess up with someone else's memory by accident (e.g. by sorting).
Carlos Martín Nieto 1c967df3 2013-11-02T00:51:57 remote: fix a couple of leaks
Carlos Martín Nieto 359dce72 2013-11-02T00:05:32 remote: make _ls return the list directly The callback-based method of listing remote references dates back to the beginning of the network code's lifetime, when we didn't know any better. We need to keep the list around for update_tips() after disconnect() so let's make use of this to simply give the user a pointer to the array so they can write straightforward code instead of having to go through a callback.
Carlos Martín Nieto 266af6d8 2013-10-30T13:44:22 remote: don't allow such direct access to the refspecs Removing arbitrary refspecs makes things more complex to reason about. Instead, let the user set the fetch and push refspec list to whatever they want it to be.
Victor Garcia 40b99d05 2013-11-08T12:14:31 splitting funcionality in two methods to avoid ambiguity with NULL
Victor Garcia 0fe522d1 2013-11-07T14:16:20 allowing create remote with custom fetch spec
Carlos Martín Nieto af613ecd 2013-10-28T23:30:45 remote: store dwimed refspecs separately This allows us to add e.g. "HEAD" as a refspec when none are given without overwriting the user's data.
Carlos Martín Nieto 968c7d07 2013-10-26T17:35:12 remote: create FETCH_HEAD with a refspecless remote When downloading the default branch due to lack of refspecs, we still need to write out FETCH_HEAD with the tip we downloaded, unfortunately with a format that doesn't match what we already have.
Daniel Rodríguez Troitiño 376454d0 2013-10-31T23:42:04 Set new multivar values using unmatcheable regexp. Seems that regexp in Mac OS X and Linux were behaving differently: while in OS X the empty string didn't match any value, in Linux it was matching all of them, so the the second fetch refspec was overwritting the first one, instead of creating a new one. Using an unmatcheable regular expression solves the problem (and seems to be portable).
Daniel Rodríguez Troitiño 3793fa9b 2013-10-31T01:08:50 Fix saving remotes with several fetch/push ref specs. At some moment git_config_delete_entry lost the ability to delete one entry of a multivar configuration. The moment you had more than one fetch or push ref spec for a remote you will not be able to save that remote anymore. The changes in network::remote::remotes::save show that problem. I needed to create a new git_config_delete_multivar because I was not able to remove one or several entries of a multivar config with the current API. Several tries modifying how git_config_set_multivar(..., NULL) behaved were not successful. git_config_delete_multivar is very similar to git_config_set_multivar, and delegates into config_delete_multivar of config_file. This function search for the cvar_t that will be deleted, storing them in a temporal array, and rebuilding the linked list. After calling config_write to delete the entries, the cvar_t stored in the temporal array are freed. There is a little fix in config_write, it avoids an infinite loop when using a regular expression (case for the multivars). This error was found by the test network::remote::remotes::tagopt.
Cheng Zhao 157cef10 2013-10-28T12:57:15 The "common.h" should be included before "config.h". When building libgit2 for ia32 architecture on a x64 machine, including "config.h" without a "common.h" would result the following error: C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2288): error C2373: 'InterlockedIncrement' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj] C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2295): error C2373: 'InterlockedDecrement' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj] C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2303): error C2373: 'InterlockedExchange' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj] C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winbase.h(2314): error C2373: 'InterlockedExchangeAdd' : redefinition; different type modifiers [C:\cygwin\home\zcbenz\codes\git-utils\build\libgit2.vcxproj]
Carlos Martín Nieto 0e0cf787 2013-10-02T14:04:44 clone: put the callbacks struct directly in the clone options There's no need for this to be a pointer to somewhere else.
Carlos Martín Nieto fe3a40a4 2013-09-16T16:54:37 remote: add a convenience 'fetch' function.
Carlos Martín Nieto e3c131c5 2013-09-16T05:02:25 remote: move the credentials callback to the struct Move this one as well, letting us have a single way of setting the callbacks for the remote, and removing fields from the clone options.
Carlos Martín Nieto d31402a3 2013-09-16T04:20:05 remote: put the _download() callback with the others The text progress and update_tips callbacks are already part of the struct, which was meant to unify the callback setup, but the download one was left out.
Russell Belfer 106c12f1 2013-09-23T13:31:15 Remove regex usage from places that don't need it In revwalk, we are doing a very simple check to see if a string contains wildcard characters, so a full regular expression match is not needed. In remote listing, now that we have git_config_foreach_match with full regular expression matching, we can take advantage of that and eliminate the regex here, replacing it with much simpler string manipulation.
Vicent Martí 92d19d16 2013-09-21T09:34:03 Merge pull request #1840 from linquize/warning Fix warning
Linquize 66566516 2013-09-08T17:15:42 Fix warning
Carlos Martín Nieto 605da51a 2013-09-17T09:50:30 No such thing as an orphan branch Unfortunately git-core uses the term "unborn branch" and "orphan branch" interchangeably. However, "orphan" is only really there for the checkout command, which has the `--orphan` option so it doesn't actually create the branch. Branches never have parents, so the distinction of a branch with no parents is odd to begin with. Crucially, the error messages deal with unborn branches, so let's use that.
Vicent Martí 1ef05e3f 2013-08-28T06:05:50 Merge pull request #1803 from libgit2/ntk/topic/even_more_lenient_remote_parsing Even more lenient remote parsing
Vicent Martí b8b22d77 2013-08-28T06:04:51 Merge pull request #1772 from libgit2/config-iter Configuration iterators redux
nulltoken aec87f71 2013-08-27T19:14:18 remote: Make git_remote_list() detect pushurl
nulltoken c9ffa84b 2013-08-21T16:04:25 remote: Relax the parsing logic even more In order to be loaded, a remote needs to be configured with at least a `url` or a `pushurl`. ENOTFOUND will be returned when trying to git_remote_load() a remote with neither of these entries defined.
nulltoken ece24ef7 2013-08-21T13:37:21 remote: Don't parse missing urls as empty strings