summaryrefslogtreecommitdiff
path: root/src/remote.c
Commit message (Collapse)AuthorAgeFilesLines
* repository: introduce a convenience config snapshot methodcmn/config-snapshotCarlos Martín Nieto2014-05-071-5/+2
| | | | | | 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.
* Use config snapshottingCarlos Martín Nieto2014-04-181-2/+6
| | | | | This way we can assume we have a consistent view of the config situation when we're looking up remote, branch, pack-objects, etc.
* Merge pull request #2215 from libgit2/rb/submodule-cache-fixesVicent Marti2014-04-041-51/+35
|\ | | | | Improve submodule cache management
| * Fix git_submodule_sync and add new config helperRussell Belfer2014-04-011-51/+35
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | remote: mark branch for-merge even if we're unbornCarlos Martín Nieto2014-04-021-7/+20
|/ | | | | | | | | | | 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.
* remote: rename inmemory to anonymous and swap url and fetch orderCarlos Martín Nieto2014-04-011-4/+4
| | | | | | | | | | 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.
* Added function-based initializers for every options struct.Matthew Bowen2014-03-051-0/+12
| | | | The basic structure of each function is courtesy of arrbee.
* Fixed missing error check on call to git_remote_download in ↵Brian Lambert2014-03-051-2/+5
| | | | 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.
* Correct default reflog message for git_remote_fetchBen Straub2014-02-061-1/+12
|
* Add reflog parameters to remote apisBen Straub2014-02-041-7/+19
| | | Also added a test for git_remote_fetch.
* Ensure renaming a reference updates the reflogBen Straub2014-01-301-10/+18
|
* refspec: move to git_buf for outputting stringsCarlos Martín Nieto2014-01-271-2/+2
|
* Make sure git_remote_dup copies a remote's refspecs correctly.Arthur Schreiber2014-01-261-8/+26
|
* Add some missing const declarations.Arthur Schreiber2014-01-261-7/+7
|
* refs: remove the _with_log differentiationCarlos Martín Nieto2014-01-151-1/+1
| | | | | | 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.
* We don't need memset here.Arthur Schreiber2014-01-141-2/+0
|
* Don't duplicate state that's only used when fetching.Arthur Schreiber2014-01-141-1/+0
|
* Add `git_remote_dup`.Arthur Schreiber2014-01-141-0/+41
|
* Cleanups, renames, and leak fixesRussell Belfer2013-12-121-2/+2
| | | | | | | | | 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.
* One more rename/cleanup for callback err functionsRussell Belfer2013-12-111-1/+1
|
* Some callback error check style cleanupsRussell Belfer2013-12-111-2/+4
| | | | I find this easier to read...
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-61/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add git_vector_free_allRussell Belfer2013-12-111-12/+2
| | | | | | 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.
* Further EUSER and error propagation fixesRussell Belfer2013-12-111-24/+23
| | | | | | | | | | | | | 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.
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-58/+66
| | | | | | | | | | | 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.
* Add config read fns with controlled error behaviorRussell Belfer2013-12-111-37/+26
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #1967 from victorgp/cleaning-code-minor-changeVicent Martí2013-11-191-4/+0
|\ | | | | Cleaning code, removing unused variables
| * cleaning code, removing unused variablesVictor Garcia2013-11-191-4/+0
| |
* | Fix warningsRussell Belfer2013-11-181-3/+3
| |
* | Propagate auth error codes as GIT_EUSER in winhttpEdward Thomson2013-11-181-27/+44
|/
* Merge pull request #1951 from victorgp/create-remote-plus-fetchVicent Martí2013-11-141-0/+30
|\ | | | | Allowing create remotes with custom fetch spec
| * splitting funcionality in two methods to avoid ambiguity with NULLVictor Garcia2013-11-081-6/+33
| |
| * allowing create remote with custom fetch specVictor Garcia2013-11-071-4/+7
| |
* | remote: let's at least pretend to have some memory safetyCarlos Martín Nieto2013-11-111-3/+27
| | | | | | | | | | | | 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).
* | remote: fix a couple of leaksCarlos Martín Nieto2013-11-111-6/+0
| |
* | remote: make _ls return the list directlyCarlos Martín Nieto2013-11-111-16/+5
| | | | | | | | | | | | | | | | | | | | | | 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.
* | remote: don't allow such direct access to the refspecsCarlos Martín Nieto2013-11-101-20/+56
| | | | | | | | | | | | 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.
* | remote: store dwimed refspecs separatelyCarlos Martín Nieto2013-11-011-76/+35
| | | | | | | | | | This allows us to add e.g. "HEAD" as a refspec when none are given without overwriting the user's data.
* | remote: create FETCH_HEAD with a refspecless remoteCarlos Martín Nieto2013-11-011-0/+21
|/ | | | | | 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.
* Set new multivar values using unmatcheable regexp.Daniel Rodríguez Troitiño2013-11-011-1/+4
| | | | | | | | | | | 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).
* Fix saving remotes with several fetch/push ref specs.Daniel Rodríguez Troitiño2013-11-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | 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.
* The "common.h" should be included before "config.h".Cheng Zhao2013-10-281-0/+1
| | | | | | | | | 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]
* clone: put the callbacks struct directly in the clone optionsCarlos Martín Nieto2013-10-021-2/+2
| | | | There's no need for this to be a pointer to somewhere else.
* remote: add a convenience 'fetch' function.Carlos Martín Nieto2013-10-021-0/+18
|
* remote: move the credentials callback to the structCarlos Martín Nieto2013-10-021-12/+1
| | | | | 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.
* remote: put the _download() callback with the othersCarlos Martín Nieto2013-10-021-5/+2
| | | | | | 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.
* Remove regex usage from places that don't need itRussell Belfer2013-09-231-29/+15
| | | | | | | | | | | 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.
* Merge pull request #1840 from linquize/warningVicent Martí2013-09-211-2/+2
|\ | | | | Fix warning
| * Fix warningLinquize2013-09-191-2/+2
| |
* | No such thing as an orphan branchCarlos Martín Nieto2013-09-171-1/+1
|/ | | | | | | | | | | 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.