Commit Graph

353 Commits

Author SHA1 Message Date
Christopher Bargren
61189a115b Fixing a code style issue 2017-02-10 07:59:22 -07:00
Christopher Bargren
2af282d835 Addressing PR feedback 2017-02-08 15:01:30 -07:00
Christopher Bargren
5f3276c7e6 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.
2017-02-08 15:01:24 -07:00
Edward Thomson
909d549436 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
2016-12-29 12:26:03 +00:00
David Turner
d81cb2e405 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
2016-07-15 13:47:01 -04:00
Patrick Steinhardt
fe345c7306 Remove unused static functions 2016-06-21 07:58:33 +02:00
Jason Haslam
7f9673e415 fetch: Fixed spurious update callback for existing tags. 2016-06-14 14:46:12 -06:00
Carlos Martín Nieto
07bd3e57d9 proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
Patrick Steinhardt
d0cb11e794 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.
2016-02-23 12:07:36 +01:00
Matt Burke
d7375662e7 Copy custom_headers insteach of referencing the caller's copy 2015-09-25 10:16:30 -04:00
Matt Burke
d16c1b978f These can be static 2015-09-24 10:32:29 -04:00
Matt Burke
d29c5412aa Avoid segfault when opts == NULL 2015-09-10 14:16:39 -04:00
Matt Burke
c49126c87f Accept custom headers for fetch too 2015-09-10 08:34:35 -04:00
Matt Burke
4f2b6093a6 Tell the git_transport about the custom_headers 2015-09-08 14:02:33 -04:00
Matt Burke
24f5b4e155 Drop extra_http_headers from git_remote 2015-09-08 14:01:57 -04:00
Matt Burke
59d6128e27 Allow the world to set HTTP headers for remotes 2015-09-04 09:36:50 -04:00
Matt Burke
ac9b512789 Pull extra_http_headers from the git_remote 2015-09-04 09:20:45 -04:00
Carlos Martín Nieto
e3e017d483 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.
2015-08-11 22:51:53 +02:00
Edward Thomson
e069c621bd 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).
2015-07-02 16:35:43 +00:00
Edward Thomson
c0280bdd15 Merge pull request #3255 from libgit2/cmn/rename-unspecified
Rename FALLBACK to UNSPECIFIED
2015-06-25 18:55:48 -04:00
Carlos Martín Nieto
23aa7c9037 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.
2015-06-25 13:40:38 +02:00
Carlos Martín Nieto
c2418f4613 Rename FALLBACK to UNSPECIFIED
Fallback describes the mechanism, while unspecified explains what the
user is thinking.
2015-06-25 12:48:44 +02:00
Carlos Martín Nieto
47a40d1d44 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.
2015-06-16 14:04:23 +02:00
Carlos Martín Nieto
2785544fb5 remote: some error-handling issues from Coverity 2015-06-07 10:45:39 +02:00
Patrick Steinhardt
ec0c4c4001 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".
2015-05-31 13:21:53 +02:00
Carlos Martín Nieto
9566ce430f 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.
2015-05-28 15:32:20 +02:00
Carlos Martín Nieto
c6e942fb3d 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.
2015-05-28 15:32:20 +02:00
Carlos Martín Nieto
ae5b93629c 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.
2015-05-28 15:32:20 +02:00
Carlos Martín Nieto
70f7484d2a 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.
2015-05-17 15:45:37 +02:00
Carlos Martín Nieto
3e20154a9d 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
a4b6452a6a remote: remove git_remote_save()
It has now become a no-op, so remove the function and all references to
it.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
7725499072 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
35a8a8c546 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
3eff2a5728 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
058b753ceb 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
6fb373a0e8 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
22261344de 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.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
8f0104ecc5 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.
2015-05-13 09:46:35 +02:00
Carlos Martín Nieto
0525911442 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.
2015-05-13 09:46:35 +02:00
Edward Thomson
cbe8a61dfa Merge pull request #3059 from libgit2/cmn/negotiation-notify
[WIP/RFC] push: report the update plan to the caller
2015-05-01 11:28:54 -04:00
Leo Yang
69f0032b4c 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.
2015-04-28 12:40:20 -04:00
Carlos Martín Nieto
efc2fec50e 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.
2015-04-19 01:02:29 +02:00
Carlos Martín Nieto
03b51b5d94 Merge pull request #2955 from git-up/update_tips_fixes
Update tips fixes
2015-03-18 05:04:12 +01:00
Sebastian Bauer
cdedef4061 Initialize refs vector in git_remote_update_tips().
Otherwise, bailing out early when ls_to_vector() fails accesses
uninitialized memory.
2015-03-17 22:03:51 +01:00
Pierre-Olivier Latour
1034f1b583 Fixed active refspecs not reset by git_remote_upload() 2015-03-11 11:51:12 -07:00
Carlos Martín Nieto
9a97f49e3a 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.
2015-03-03 18:35:12 +01:00
Carlos Martín Nieto
412a380888 push: remove reflog message override
We always use "update by push".
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
659cf2029f 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.
2015-03-03 14:40:50 +01:00
Edward Thomson
392702ee2c allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic
and set error message appropriately.
2015-02-12 22:54:46 -05:00
Edward Thomson
a8846da7b3 remote: plug leak 2015-01-08 13:45:22 -06:00