src/remote.c


Log

Author Commit Date CI Message
Patrick Steinhardt a54043b7 2018-09-21T15:32:18 Merge pull request #4794 from marcin-krystianc/mkrystianc/prune_perf git_remote_prune to be O(n * logn)
Etienne Samson 1c176883 2018-09-07T10:36:15 remote: store the connection data in a private struct This makes it easier to pass connection-related options around (proxy & custom headers for now). This fixes a bug in git_push_finish, which didn't reuse the provided proxy if the connection closed between the call to `git_remote_push` and the finish step.
Marcin Krystianc bfec6526 2018-09-02T11:38:43 git_remote_prune to be O(n * logn)
Etienne Samson 22d013b6 2018-08-21T01:55:56 remote: set the error before cleanup Otherwise we'll return stack data to the caller.
Patrick Steinhardt af3088e4 2018-06-29T11:45:15 refspec: rename `git_refspec__free` to `git_refspec__dispose` Since commit 630a67366 (refspec: add public parsing api, 2018-02-07), we now have two functions `git_refspec_free` and `git_refspec__free`. The difference is that the first one will free the structure itself, while the second one will only free the structure's contents. Use our new `dispose` naming pattern for the latter function to help avoid confusion.
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Etienne Samson df4937b8 2018-04-18T20:57:16 remote: repo is optional here As per CID:1378747, we might be called with a NULL repo, which would be deferenced in write_add_refspec
Carlos Martín Nieto 1b4fbf2e 2017-11-19T09:47:07 remote: append to FETCH_HEAD rather than overwrite for each refspec We treat each refspec on its own, but the code currently overwrites the contents of FETCH_HEAD so we end up with the entries for the last refspec we processed. Instead, truncate it before performing the updates and append to it when updating the references.
Edward Thomson 1560b580 2017-08-15T10:35:47 Merge pull request #4288 from pks-t/pks/include-fixups Include fixups
Patrick Steinhardt 0c7f49dd 2017-06-30T13:39:01 Make sure to always include "common.h" first Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
Eric Myhre 4bc16c37 2016-07-08T01:37:22 remote: add function to create detached remotes Right now it is only possible to create remotes from a repository. While this is probably the most common use-case, there are commands which make sense even without a repository, e.g. the equivalence of `git ls-remote`. Add a new function `git_remote_create_detached`, which simply accepts a URL.
Patrick Steinhardt 8897f8fe 2017-05-05T09:47:54 remote: reject various actions for detached remotes There are only few actions which actually make sense for a detached remote, like e.g. `git_remote_ls`, `git_remote_prune`. For all the other actions, we have to report an error when the remote has no repository attached to it. This commit does so and implements some tests.
Patrick Steinhardt fd2ff8c9 2017-05-05T09:21:58 remote: improve error message if no URL is set The current error message when connecting to a remote when no URL is set is missing information on whether it is missing a fetch or push URL. Furthermore, it results in undefined behavior when using a remote without name. Fix both issues.
Edward Thomson 4dbcf0e6 2017-05-01T19:34:04 remote: free the config snapshot This reverts commit 5552237 and frees the snapshot properly.
Edward Thomson f86f35d6 2017-05-01T15:23:54 Merge branch 'pr/4225'
Yichao Yu 90cdf44f 2017-04-29T13:00:07 Allow NULL refspec in git_remote_push Since this is allowed in `git_remote_upload`
Yichao Yu 55522376 2017-04-29T12:28:35 Do not free config when creating remote The regression was introduced in 22261344de18b3cc60ee6937468d66a6a6a28875
Christopher Bargren 61189a11 2017-02-10T07:59:22 Fixing a code style issue
Christopher Bargren 2af282d8 2017-02-08T15:01:30 Addressing PR feedback
Christopher Bargren 5f3276c7 2017-02-07T16:33:28 Add support for lowercase proxy environment variables curl supports HTTPS_PROXY in addition to https_proxy (and their http counterparts). This change ensures parity with curl's behavior.
Edward Thomson 909d5494 2016-12-29T12:25:15 giterr_set: consistent error messages Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
David Turner d81cb2e4 2016-07-15T13:32:23 remote: Handle missing config values when deleting a remote Somehow I ended up with the following in my ~/.gitconfig: [branch "master"] remote = origin merge = master rebase = true I assume something went crazy while I was running the git.git tests some time ago, and that I never noticed until now. This is not a good configuration, but it shouldn't cause problems. But it does. Specifically, if you have this in your config, and you perform the following set of actions: create a remote fetch from that remote create a branch off of the remote master branch called "master" delete the branch delete the remote The remote delete fails with the message "Could not find key 'branch.master.rebase' to delete". This is because it's iterating over the config entries (including the ones in the global config) and believes that there is a master branch which must therefore have these config keys. https://github.com/libgit2/libgit2/issues/3856
Patrick Steinhardt fe345c73 2016-02-09T12:29:31 Remove unused static functions
Jason Haslam 7f9673e4 2016-06-14T14:46:12 fetch: Fixed spurious update callback for existing tags.
Carlos Martín Nieto 07bd3e57 2015-05-07T12:57:56 proxy: ask the user for credentials if necessary
Patrick Steinhardt d0cb11e7 2016-02-22T16:01:03 remote: set error code in `create_internal` Set the error code when an error occurs in any of the called functions. This ensures we pass the error up to callers and actually free the remote when an error occurs.
Matt Burke d7375662 2015-09-25T10:16:16 Copy custom_headers insteach of referencing the caller's copy
Matt Burke d16c1b97 2015-09-24T10:30:37 These can be static
Matt Burke d29c5412 2015-09-10T14:16:39 Avoid segfault when opts == NULL
Matt Burke c49126c8 2015-09-10T08:34:35 Accept custom headers for fetch too
Matt Burke 4f2b6093 2015-09-08T13:53:41 Tell the git_transport about the custom_headers
Matt Burke 24f5b4e1 2015-09-08T13:34:42 Drop extra_http_headers from git_remote
Matt Burke 59d6128e 2015-09-04T09:36:50 Allow the world to set HTTP headers for remotes
Matt Burke ac9b5127 2015-09-04T09:20:45 Pull extra_http_headers from the git_remote
Carlos Martín Nieto e3e017d4 2015-08-11T22:51:53 remote: don't confuse tag auto-follow rules with refspec matching When we're looking to update a tag, we can't stop if the tag auto-follow rules don't say to update it. The tag might still match the refspec we were given.
Edward Thomson e069c621 2015-07-02T09:25:48 git__getenv: utf-8 aware env reader Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere. Make `cl_getenv` use this to keep consistent memory handling around return values (free everywhere, as opposed to only some platforms).
Edward Thomson c0280bdd 2015-06-25T18:55:48 Merge pull request #3255 from libgit2/cmn/rename-unspecified Rename FALLBACK to UNSPECIFIED
Carlos Martín Nieto 23aa7c90 2015-06-25T13:40:38 remote: insert refspecs with no rhs in FETCH_HEAD When a refspec contains no rhs and thus won't cause an explicit update, we skip all the logic, but that means that we don't update FETCH_HEAD with it, which is what the implicit rhs is. Add another bit of logic which puts those remote heads in the list of updates so we put them into FETCH_HEAD.
Carlos Martín Nieto c2418f46 2015-06-25T12:48:44 Rename FALLBACK to UNSPECIFIED Fallback describes the mechanism, while unspecified explains what the user is thinking.
Carlos Martín Nieto 47a40d1d 2015-06-16T12:39:11 remote: return EINVALIDSPEC when given an empty URL This is what we used to return in the settter and there's tests in bindings which ask for this. There's no particular reason to stop doing so.
Carlos Martín Nieto 2785544f 2015-06-07T10:45:39 remote: some error-handling issues from Coverity
Patrick Steinhardt ec0c4c40 2015-05-04T11:59:20 remote: apply insteadOf configuration. A remote's URLs are now modified according to the url.*.insteadOf and url.*.pushInsteadOf configurations. This allows a user to replace URL prefixes by setting the corresponding keys. E.g. "url.foo.insteadOf = bar" would replace the prefix "bar" with the new prefix "foo".
Carlos Martín Nieto 9566ce43 2015-05-18T14:42:35 remote: call the update_tips callback for opportunisitc updates These are updates, same as the rest, we should call this callback. As we are using the callback, let's make sure to skip unnecessary updates.
Carlos Martín Nieto c6e942fb 2015-05-17T15:19:22 remote: validate refspecs before adding to config When we moved from acting on the instance to acting on the configuration, we dropped the validation of the passed refspec, which can lead to writing an invalid refspec to the configuration. Bring that validation back.
Carlos Martín Nieto ae5b9362 2015-05-17T15:11:45 remote: remove fetch parameter from create_anonymous An anonymous remote is not configured and cannot therefore have configured refspecs. Remove the parameter which adds this from the constructor.
Carlos Martín Nieto 70f7484d 2015-05-14T09:35:08 remote: get rid of the run-time refspec setters These were left over from the culling as it's not clear which use-cases might benefit from this. It is not clear that we want to support any use-case which depends on changing the remote's idea of the base refspecs rather than passing in different per-operation refspec list, so remove these functions.
Carlos Martín Nieto 3e20154a 2015-04-25T00:38:22 remote: simplify anonymous creation We're down to simply having it be a call to create_internal() so let's simply do that. The rest of the code is just a distraction.
Carlos Martín Nieto a4b6452a 2015-04-23T06:55:29 remote: remove git_remote_save() It has now become a no-op, so remove the function and all references to it.
Carlos Martín Nieto 77254990 2015-04-23T06:51:34 remote: remove live changing of refspecs The base refspecs changing can be a cause of confusion as to what is the current base refspec set and complicate saving the remote's configuration. Change `git_remote_add_{fetch,push}()` to update the configuration instead of an instance. This finally makes `git_remote_save()` a no-op, it will be removed in a later commit.
Carlos Martín Nieto 35a8a8c5 2015-04-22T17:29:20 remote: move the tagopt setting to the fetch options This is another option which we should not be keeping in the remote, but is specific to each particular operation.
Carlos Martín Nieto 3eff2a57 2015-04-22T16:11:10 remote: move the update_fetchhead setting to the options While this will rarely be different from the default, having it in the remote adds yet another setting it has to keep around and can affect its behaviour. Move it to the options.
Carlos Martín Nieto 058b753c 2015-04-22T15:45:21 remote: move the transport ctor to the callbacks Instead of having it set in a different place from every other callback, put it the main structure. This removes some state from the remote and makes it behave more like clone, where the constructors are passed via the options.
Carlos Martín Nieto 6fb373a0 2015-04-22T04:54:00 remote: add prune option to fetch Add a prune setting in the fetch options to allow to fall back to the configuration (the default) or to set it on or off.
Carlos Martín Nieto 22261344 2015-04-22T04:38:08 remote: remove url and pushurl from the save logic As a first step in removing the repository-saving logic, don't allow chaning the url or push url from a remote object, but change the configuration on the configuration immediately.
Carlos Martín Nieto 8f0104ec 2015-04-21T22:10:36 Remove the callbacks struct from the remote Having the setting be different from calling its actions was not a great idea and made for the sake of the wrong convenience. Instead of that, accept either fetch options, push options or the callbacks when dealing with the remote. The fetch options are currently only the callbacks, but more options will be moved from setters and getters on the remote to the options. This does mean passing the same struct along the different functions but the typical use-case will only call git_remote_fetch() or git_remote_push() and so won't notice much difference.
Carlos Martín Nieto 05259114 2015-04-21T20:16:48 push: remove own copy of callbacks The push object knows which remote it's associated with, and therefore does not need to keep its own copy of the callbacks stored in the remote. Remove the copy and simply access the callbacks struct within the remote.
Edward Thomson cbe8a61d 2015-05-01T11:28:54 Merge pull request #3059 from libgit2/cmn/negotiation-notify [WIP/RFC] push: report the update plan to the caller
Leo Yang 69f0032b 2015-04-28T12:40:20 Fix some build warnings In checkout.c and filter.c we were casting a sub struct to a parent struct which breaks the strict aliasing rules in C. However we can use .parent or .base to access the parent struct to avoid the build warnings. In remote.c the local variable error was not initialized or updated in some cases. For unintialized error a build warning will be generated. So always keep error variable up-to-date.
Carlos Martín Nieto efc2fec5 2015-04-19T00:55:00 push: report the update plan to the caller It can be useful for the caller to know which update commands will be sent to the server before the packfile is pushed up. git does this via the pre-push hook. We don't have hooks, but as it adds introspection into what is happening, we can add a callback which performs the same function.
Carlos Martín Nieto 03b51b5d 2015-03-18T05:04:12 Merge pull request #2955 from git-up/update_tips_fixes Update tips fixes
Sebastian Bauer cdedef40 2015-03-17T21:38:58 Initialize refs vector in git_remote_update_tips(). Otherwise, bailing out early when ls_to_vector() fails accesses uninitialized memory.
Pierre-Olivier Latour 1034f1b5 2015-03-05T23:06:31 Fixed active refspecs not reset by git_remote_upload()
Carlos Martín Nieto 9a97f49e 2014-12-21T15:31:03 config: borrow refcounted references This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
Carlos Martín Nieto 412a3808 2015-01-15T15:31:23 push: remove reflog message override We always use "update by push".
Carlos Martín Nieto 659cf202 2015-01-07T12:23:05 Remove the signature from ref-modifying functions The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
Edward Thomson 392702ee 2015-02-09T23:41:13 allocations: test for overflow of requested size Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
Edward Thomson a8846da7 2015-01-08T13:45:22 remote: plug leak
David Calavera 66b71ea5 2015-01-05T13:33:36 Fix intentation.
David Calavera 1ef3f0ce 2015-01-05T13:24:11 Load prune configuration when a remote is created.
Pierre-Olivier Latour c070ac64 2015-01-01T04:14:58 Fixed internal push state not being cleared on download git_remote_download() must also clear the internal push state resulting from a possible earlier push operation. Otherwise calling git_remote_update_tips() will execute the push version instead of the fetch version and among other things, tags won't be updated.
Edward Thomson a3ef70bb 2014-12-30T11:53:55 Merge pull request #2761 from libgit2/cmn/fetch-prune Remote-tracking branch prunning
Carlos Martín Nieto fe794b2e 2014-12-16T08:57:05 remote: remove git_push from the public API Instead we provide git_remote_upload() and git_remote_update_tips() in order to have a parallel API for fetching and pushing.
Carlos Martín Nieto 26186b15 2014-12-14T21:01:19 fetch: remove the prune setter This option does not get persisted to disk, which makes it different from the rest of the setters. Remove it until we go all the way. We still respect the configuration option, and it's still possible to perform a one-time prune by calling the function.
Carlos Martín Nieto 59ff8b67 2014-12-14T18:24:54 fetch: perform prune in separate steps For each remote-tracking branch we want to remove, we need to consider it against every other refspec in case we have overlapping refspecs, such as with refs/heads/*:refs/remotes/origin/* refs/pull/*/head:refs/remotes/origin/pr/* as we'd otherwise remove too many refspecs. Create a list of condidates, which are the references matching the rhs of any active refspec and then filter that list by removing those entries for which we find a remove reference with any active refspec. Those which are left after this are removed.
Carlos Martín Nieto 8c13eaed 2014-12-14T17:00:54 fetch: prune after updating tips This makes a fetch+prune more similar to a connect+prune and makes it more likely that we see errors in the decision to prune a reference.
David Calavera 439e19f6 2014-11-12T17:12:30 Test that prune overlapping works as expected.
Linquize 5f473947 2014-09-22T23:17:35 remote: prune refs when fetching
Carlos Martín Nieto d524b2d3 2014-12-10T17:23:33 push: fold unpack_ok() into finish() The push cannot be successful if we sent a bad packfile. We should return an error in that case instead of storing it elsewhere.
Carlos Martín Nieto 52ee0e8e 2014-11-23T21:26:53 remote: verify there is a push foreach callback set
Carlos Martín Nieto f7fcb18f 2014-11-23T14:12:54 Plug leaks Valgrind is now clean except for libssl and libgcrypt.
Carlos Martín Nieto 699dfcc3 2014-11-19T15:49:02 remote: clarify which list of references _ls() returns Make it clear that this is not the ls-remote command but a way to access the data we have and how long it's kept around.
Edward Thomson 45301cca 2014-11-18T11:44:59 Merge pull request #2608 from libgit2/cmn/remote-push Provide a convenience function `git_remote_push()`
Pierre-Olivier Latour d3cd7da5 2014-10-28T20:56:18 Fixed active_refspecs field not initialized on new git_remote objects When creating a new remote, contrary to loading one from disk, active_refspecs was not populated. This means that if using the new remote to push, git_push_update_tips() will be a no-op since it checks the refspecs passed during the push against the base ones i.e. active_refspecs. And therefore the local refs won't be created or updated after the push operation.
Carlos Martín Nieto 64e3e6d4 2014-10-11T12:25:50 remote: use configured push refspecs if none are given If the user does not pass any refspecs to push, try to use those configured via the configuration or via add_push().
Carlos Martín Nieto 3149547b 2014-10-10T12:39:53 remote: introduce git_remote_push() This function, similar in style to git_remote_fetch(), performs all the steps required for a push, with a similar interface. The remote callbacks struct has learnt about the push callbacks, letting us set the callbacks a single time instead of setting some in the remote and some in the push operation.
Pierre-Olivier Latour e284c451 2014-10-28T22:18:38 Changed GIT_REMOTE_DOWNLOAD_TAGS_ALL to behave like git 1.9.0
Edward Thomson 02bc5233 2014-11-08T17:05:13 Merge pull request #2698 from libgit2/cmn/fetchhead-refactor Refactor fetchhead
Carlos Martín Nieto 2c9b9c8b 2014-11-08T20:40:02 remote: refactor the reference-update decision This is an ugly chunk of code, so let's put it into its own function.
Carlos Martín Nieto 64fdd86d 2014-11-08T20:21:14 remote: don't check for upstream on an anonymous remote If the remote is anonymous, then we cannot check for any configuration, as there is no name. Check for this before we try to use the name, which may be a NULL pointer. This fixes #2697.
Carlos Martín Nieto e235db02 2014-11-08T20:09:11 remote: use git_branch_upstream_remote() This reduces the clutter somewhat and lets us see what we're asking about the reference.
Carlos Martín Nieto 209425ce 2014-11-08T13:25:51 remote: rename _load() to _lookup() This brings it in line with the rest of the lookup functions.
Edward Thomson f890a84f 2014-11-06T10:19:22 Merge pull request #2682 from libgit2/cmn/fetch-tags-refspec remote: check for the validity of the refspec when updating FETCH_HEAD
Edward Thomson cce27d82 2014-11-03T14:07:20 git_remote_rename: propogate GIT_ENOTFOUND
Carlos Martín Nieto 6d20006f 2014-11-02T20:11:54 remote: check the relevance of the refspec when updating FETCH_HEAD Before trying to rtransform using the given refspec to figure out what the name of the upstream branch is on the remote, we must make sure that the target of the refspec applies to the current branch's upstream.
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.