Commit Graph

252 Commits

Author SHA1 Message Date
Edward Thomson
80fc7d6bf0 Propagate auth error codes as GIT_EUSER in winhttp 2013-11-18 12:56:34 -05:00
Vicent Martí
7b947bf5cc Merge pull request #1951 from victorgp/create-remote-plus-fetch
Allowing create remotes with custom fetch spec
2013-11-14 07:21:47 -08:00
Carlos Martín Nieto
877cde765a 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).
2013-11-11 15:35:52 +01:00
Carlos Martín Nieto
1c967df31c remote: fix a couple of leaks 2013-11-11 15:35:52 +01:00
Carlos Martín Nieto
359dce726d 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.
2013-11-11 15:35:51 +01:00
Carlos Martín Nieto
266af6d819 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.
2013-11-10 22:21:25 +01:00
Victor Garcia
40b99d05b4 splitting funcionality in two methods to avoid ambiguity with NULL 2013-11-08 12:14:31 +01:00
Victor Garcia
0fe522d105 allowing create remote with custom fetch spec 2013-11-07 14:16:20 +01:00
Carlos Martín Nieto
af613ecd44 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.
2013-11-01 22:48:09 +01:00
Carlos Martín Nieto
968c7d072a 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.
2013-11-01 22:47:06 +01:00
Daniel Rodríguez Troitiño
376454d03d 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).
2013-11-01 00:08:52 +01:00
Daniel Rodríguez Troitiño
3793fa9b18 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.
2013-11-01 00:08:52 +01:00
Cheng Zhao
157cef1048 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]
2013-10-28 12:57:15 +08:00
Carlos Martín Nieto
0e0cf78773 clone: put the callbacks struct directly in the clone options
There's no need for this to be a pointer to somewhere else.
2013-10-02 14:04:44 +02:00
Carlos Martín Nieto
fe3a40a4ff remote: add a convenience 'fetch' function. 2013-10-02 06:41:42 +02:00
Carlos Martín Nieto
e3c131c544 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.
2013-10-02 06:41:42 +02:00
Carlos Martín Nieto
d31402a3fc 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.
2013-10-02 06:41:42 +02:00
Russell Belfer
106c12f118 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.
2013-09-23 13:31:15 -07:00
Vicent Martí
92d19d1671 Merge pull request #1840 from linquize/warning
Fix warning
2013-09-21 09:34:03 -07:00
Linquize
66566516ce Fix warning 2013-09-19 23:14:06 +08:00
Carlos Martín Nieto
605da51a2c 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.
2013-09-17 09:50:30 +02:00
Vicent Martí
1ef05e3f0e Merge pull request #1803 from libgit2/ntk/topic/even_more_lenient_remote_parsing
Even more lenient remote parsing
2013-08-28 06:05:50 -07:00
Vicent Martí
b8b22d774e Merge pull request #1772 from libgit2/config-iter
Configuration iterators redux
2013-08-28 06:04:51 -07:00
nulltoken
aec87f712f remote: Make git_remote_list() detect pushurl 2013-08-27 20:14:10 +02:00
nulltoken
c9ffa84bde 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.
2013-08-27 19:31:19 +02:00
nulltoken
ece24ef7c4 remote: Don't parse missing urls as empty strings 2013-08-27 16:57:17 +02:00
nulltoken
44bc0c6ac3 remote: Warn the user when connecting with no url 2013-08-27 16:57:16 +02:00
nulltoken
b83c92dd6f remote: Assert proper GIT_DIRECTION_XXXX values 2013-08-27 16:57:15 +02:00
Vicent Martí
ad0af71575 Merge pull request #1780 from phkelley/development
Respect GIT_SSL_NO_VERIFY and http.sslVerify
2013-08-14 06:48:09 -07:00
Carlos Martín Nieto
0b9ebb54ff remote: relax the url rules
Accept any value for the remote's url, including an empty string which
we used to reject as invalid configuration.

This is not quite what git does (although it has its own problems with
such configurations) and it makes it harder to fix the issue, by not
letting the user modify it.

As we already need to check for a valid URL when we try to connect to
the network, let that perform the check, as we don't need to do it
anywhere else.
2013-08-14 11:52:49 +02:00
Philip Kelley
af6dab7ef7 Respect GIT_SSL_NO_VERIFY and http.sslVerify 2013-08-13 15:10:03 -04:00
Carlos Martín Nieto
4efa32903a config: get_multivar -> get_multivar_foreach
The plain function will return an iterator, so move this one out of
the way.
2013-08-08 13:57:01 +02:00
Etienne Samson
85e1eded6a Add git_remote_owner 2013-07-15 16:31:25 +02:00
Russell Belfer
2f77d8f15d Fix some memory leaks 2013-06-10 14:16:56 -07:00
Vicent Martí
947fad4f7f Merge pull request #1624 from libgit2/vmg/full-ref-iterator
Breaking RefDB changes
2013-06-03 09:28:58 -07:00
yorah
df50512aeb Proposal to handle default value (auto = 0) 2013-05-30 18:06:54 +02:00
yorah
215af2ccb8 remote: make default tag retrieving behaviour consistent
Default for newly created remotes will be auto.
Default when loading existing remotes with no tag retrieving behaviour set, was already auto.
2013-05-30 17:59:11 +02:00
Vicent Marti
4e6e2ff26f ...Aaaand this works 2013-05-30 03:47:10 +02:00
Vicent Marti
56960b8396 Liike this 2013-05-28 20:47:55 +02:00
Jameson Miller
6fe02c11a6 Fetch should not fail when remote HEAD reference is not present locally 2013-05-15 14:44:35 -04:00
Edward Thomson
b6cc559a78 Merge pull request #1385 from carlosmn/refs-iter
Introduce a refs iterator
2013-05-11 02:42:49 -07:00
Carlos Martín Nieto
9bd89d9622 Move a couple more functions to use iterators 2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
2b562c3a1e refs: remove the OID/SYMBOLIC filtering
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.

As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
2013-05-11 11:20:38 +02:00
Vicent Martí
ddc5c05421 Merge pull request #1561 from arrbee/fix-windows-diff-eofnl
Fix windows diff eofnl error
2013-05-09 05:42:37 -07:00
Russell Belfer
0f938c6b8f Fix win32 type warnings 2013-05-07 09:59:53 -07:00
Carlos Martín Nieto
505b5d0c81 remote: correctly interpret tagopt '--tags'
When tagopt is set to '--tags', we should only take the default tags
refspec into account and ignore any configured ones.

Bring the code into compliance.
2013-05-07 18:49:47 +02:00
Russell Belfer
bf6bebe22e Factor out some code that needed to clear errors
A number of places were looking up option config values and then
not clearing the error codes if the values were not found.  This
moves the repeated pattern into a shared routine and adds the
extra call to giterr_clear() when needed.
2013-05-01 15:23:40 -07:00
Vicent Martí
cd2ed9f0cc Merge pull request #1518 from arrbee/export-oid-comparison
Remove most inlines from the public API
2013-04-30 04:02:52 -07:00
Carlos Martín Nieto
9c5d4b2e80 remote: fix a leak when dwim'ing refspecs 2013-04-30 12:05:16 +02:00
Carlos Martín Nieto
1ffd0806f4 remote: add resfpec list accessors
Bring back a way of acessing the git_refspec* from a remote.

Closes #1514
2013-04-30 12:04:59 +02:00
Russell Belfer
b7f167da29 Make git_oid_cmp public and add git_oid__cmp 2013-04-29 13:52:12 -07:00
Carlos Martín Nieto
d84884571d remote: dwim the refspecs according to the remote's advertised refs
As git allows you to store shorthand refspecs in the configuration, we
need to do this ourselves.
2013-04-28 18:49:51 +02:00
Carlos Martín Nieto
1be680c4d0 refspec: unify the string and parsed data
It used to be separate as an attempt to make the querying easier, but
it didn't work out that way, so put all the data together.

Add git_refspec_string() as well to get the original string, which is
now stored alongside the independent parts.
2013-04-20 19:45:40 +02:00
Carlos Martín Nieto
bc6374eac4 remote: allow querying for refspecs
Introduce git_remote_{fetch,push}_refspecs() to get a list of refspecs
from the remote and rename the refspec-adding functions to a less
silly name.

Use this instead of the vector index hacks in the tests.
2013-04-20 19:45:40 +02:00
Carlos Martín Nieto
4330ab26b5 remote: handle multiple refspecs
A remote can have a multitude of refspecs. Up to now our git_remote's
have supported a single one for each fetch and push out of simplicity
to get something working.

Let the remotes and internal code know about multiple remotes and get
the tests passing with them.

Instead of setting a refspec, the external users can clear all and add
refspecs. This should be enough for most uses, though we're still
missing a querying function.
2013-04-20 17:54:13 +02:00
Carlos Martín Nieto
404eadb089 remote: don't try to update FETCH_HEAD if no extra heads exist
Don't try to update anything if there are no heads to update. This
saves us from trying to look into a fetch refspec when there is none.

A better fix for compatibility with git when using remotes without
refspecs is still needed, but this stops us from segfaulting.
2013-04-16 00:11:59 +02:00
Carlos Martín Nieto
67ba7d2031 Allow git_remote_ls after disconnecting from the remote
Keep the data around until free, as expected by our own fetch example
2013-04-15 23:22:32 +02:00
Carlos Martín Nieto
a258d8e357 branch: rename 'tracking' to 'upstream'
The term 'tracking' is overloaded. Help distinguish what we mean by
using 'upstream' for this part of the library.
2013-03-30 15:45:57 +01:00
Arkadiy Shapkin
10c06114cb Several warnings detected by static code analyzer fixed
Implicit type conversion argument of function to size_t type
Suspicious sequence of types castings: size_t -> int -> size_t
Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)'
Unsigned type is never < 0
2013-03-18 03:30:26 +04:00
Edward Thomson
d00d54645d immutable references and a pluggable ref database 2013-03-07 11:01:52 -06:00
nulltoken
2bca5b679b remote: Introduce git_remote_is_valid_name()
Fix libgit2/libgit2sharp#318
2013-02-11 23:19:41 +01:00
Philip Kelley
11d9f6b304 Vector improvements and their fallout 2013-01-27 14:17:07 -05:00
nulltoken
c5193e3c20 clone: Prevent segfault upon faulted remote creation 2013-01-25 12:26:09 +01:00
Ben Straub
3874f2d54f Kill vestigal dangling-remote code
Fixes #1232
2013-01-11 20:23:46 -08:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Ben Straub
c07b52df1b Remove inmem flag, use NULL name instead 2013-01-02 12:48:17 -08:00
Ben Straub
0642c1431e Move url to last place in parameter list 2013-01-02 12:44:47 -08:00
Ben Straub
592f466c48 Fix GCC static/non-static compile error 2012-12-27 11:11:53 -08:00
nulltoken
f19304d265 remote: Prevent create() from blindly overwriting 2012-12-24 18:18:31 +01:00
nulltoken
7d4b65f608 Fix indentations 2012-12-24 16:54:27 +01:00
Ben Straub
79000951ec In-memory remotes don't have names 2012-12-21 08:05:59 -08:00
Ben Straub
874dcb25eb Remote: deprecate dangling, prevent saving in-memory 2012-12-20 12:01:13 -08:00
Ben Straub
29f27599ea Rename remote creation APIs
git_remote_add -> git_remote_create
git_remote_new -> git_remote_create_inmemory
2012-12-20 10:52:57 -08:00
Ben Straub
7c353afd0e Define constant for default fetch spec 2012-12-13 08:47:29 -08:00
Ben Straub
44f36f6e3b Convert clone to use dangling remotes 2012-12-12 19:48:44 -08:00
Ben Straub
b914e17d82 API to set a dangling remote's repository 2012-12-12 12:23:24 -08:00
Ben Straub
a71c27ccda Allow creation of dangling remotes 2012-12-12 12:15:25 -08:00
Ben Straub
59bccf33c4 Add a payload param to git_cred_acquire_cb
Fixes #1128.
2012-12-10 11:11:01 -08:00
Vicent Martí
e05ca13f1f Merge pull request #1115 from ben/struct-versions
Version info for public structs
2012-12-05 11:47:19 -08:00
nulltoken
032ba9e4ad remote: deploy EINVALIDSPEC usage 2012-12-01 08:34:23 +01:00
Ben Straub
c7231c45fe Deploy GITERR_CHECK_VERSION 2012-11-30 16:31:42 -08:00
Ben Straub
1071176900 Deploy versioned git_transport structure 2012-11-30 13:12:15 -08:00
Ben Straub
9267ff586f Deploy GIT_REMOTE_CALLBACKS_INIT 2012-11-30 13:12:15 -08:00
Philip Kelley
613d5eb939 Push! By schu, phkelley, and congyiwu, et al 2012-11-28 11:42:37 -05:00
Ben Straub
f4a62c306d Typedef enums. 2012-11-27 14:13:03 -08:00
Ben Straub
df705148ec API updates for remote.h
Includes typedef for git_direction, and renames for
GIT_DIR_[FETCH|PUSH] to GIT_DIRECTION_(\1).
2012-11-27 13:19:49 -08:00
Ben Straub
54b2a37ac7 Clean up config.h 2012-11-27 13:18:28 -08:00
Ben Straub
2508cc66eb Rename ref and reflog apis for consistency 2012-11-27 13:17:45 -08:00
Carlos Martín Nieto
0da81d2b39 config: return an emtpy string when there is no value
Returning NULL for the string when we haven't signaled an error
condition is counter-intuitive and causes unnecessary edge
cases. Return an empty string when asking for a string value for a
configuration variable such as '[section] var' to avoid these edge
cases.

If the distinction between no value and an empty value is needed, this
can be retrieved from the entry directly. As a side-effect, this
change stops the int parsing functions from segfaulting on such a
variable.
2012-11-13 14:49:16 -08:00
Carlos Martín Nieto
47db054df0 config: distinguish between a lone variable name and one without rhs
'[section] variable' and '[section] variable =' behave differently
when parsed as booleans, so we need to store that distinction
internally.
2012-11-13 13:53:41 -08:00
Edward Thomson
b0f6e45d14 create FETCH_HEAD specially instead of as a ref file 2012-11-11 11:56:33 -06:00
Philip Kelley
091361f569 Basic authentication for http and winhttp 2012-11-06 08:52:03 -05:00
Justin Spahr-Summers
c1cd036e40 'geterr' -> 'giterr' 2012-11-05 11:01:00 -08:00
Justin Spahr-Summers
f8baece754 Set GITERR_INVALID when encountering a NULL remote URL 2012-11-05 10:42:10 -08:00
Justin Spahr-Summers
83885891f5 Bail out if remote->url would be NULL
This fixes a crash from attempting to invoke git__strdup() against NULL.
2012-11-04 22:01:24 -08:00
Vicent Martí
7ae73e94db Merge pull request #1030 from pwkelley/transports
Reorganize transport architecture
2012-11-01 09:15:29 -07:00
Philip Kelley
41fb1ca0ec Reorganize transport architecture (squashed 3) 2012-11-01 09:02:33 -04:00
Ben Straub
c48e87006c Ensure that non-error is not propagated 2012-10-31 10:13:57 -07:00
Michael Schubert
6cfbbf7e32 Fix a couple of warnings 2012-10-30 18:50:59 +01:00
Russell Belfer
1b9346897b Merge pull request #925 from nulltoken/topic/moving-branch-updates-config
Updates config upon moving and deletion of branches
2012-10-25 10:55:03 -07:00