Commit Graph

3947 Commits

Author SHA1 Message Date
Carlos Martín Nieto
a6192d7c98 remote: update head list on push
A previous commit forgot to update the head list after push as well,
leading to wrong output of git_remote_ls().
2013-11-11 15:35:52 +01: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
Vicent Marti
a1d35ede18 config_file: style 2013-11-10 16:41:41 +01:00
Vicent Martí
b9cb72c28a Merge pull request #1950 from csware/quote-config-values
Correctly quote config values while saving
2013-11-10 07:33:11 -08:00
Vicent Martí
0df96f2b05 Merge pull request #1936 from libgit2/better-url-parsing
Streamline url-parsing logic.
2013-11-10 07:31:21 -08:00
Victor Garcia
40b99d05b4 splitting funcionality in two methods to avoid ambiguity with NULL 2013-11-08 12:14:31 +01:00
Edward Thomson
1e60e5f42d Allow callers to set mode on packfile creation 2013-11-07 12:04:32 -05:00
Sven Strickroth
590c5efb3b Rename method
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-11-07 17:51:43 +01:00
Edward Thomson
cc2447da32 Add git_packbuilder_hash to query pack filename 2013-11-07 09:43:24 -05:00
Victor Garcia
0fe522d105 allowing create remote with custom fetch spec 2013-11-07 14:16:20 +01:00
Sven Strickroth
fde9325032 Correctly quote config values while saving
If the value contains a command (; or #) char or starts or ends with space it needs to be quoted.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-11-07 13:31:25 +01:00
Edward Thomson
7616b8d3ce don't double free pkt 2013-11-05 17:35:50 -06:00
Carlos Martín Nieto
a8baf4b160 Merge pull request #1946 from arthurschreiber/change-branch-iterator-definition
Change the git_branch_iterator_new definition to use git_branch_t
2013-11-05 12:26:41 -08:00
Arthur Schreiber
a667ca8298 Change the git_branch_iterator_new and git_branch_next definitions to use git_branch_t. 2013-11-05 20:51:07 +01:00
Ben Straub
8adea28ae9 Blame: change signature to be more binding-friendly 2013-11-05 11:44:42 -08:00
Ben Straub
79c443425b Make url decoding more bulletproof 2013-11-05 11:35:57 -08:00
Ben Straub
aad5403fe9 Fix MSVC 64-bit warnings 2013-11-05 10:55:54 -08:00
Ben Straub
d6eb3f9ce7 Remove unnecessary check 2013-11-05 10:54:44 -08:00
Ben Straub
fe294b95d1 Incorporate feedback 2013-11-05 10:37:50 -08:00
nulltoken
39b1ad7f15 Plug configuration file search paths leaks 2013-11-05 17:36:12 +01:00
nulltoken
8d22773f4b Plug git_merge() related leaks 2013-11-05 17:30:11 +01:00
Edward Thomson
039db728f3 merge branch into current, updating workdir 2013-11-05 10:00:39 -05:00
Vicent Martí
ae26c4b80f Merge pull request #1943 from libgit2/ntk/fix/leaks
Fix leaks
2013-11-05 06:55:29 -08:00
Vicent Martí
c82f7f8e99 Merge pull request #1938 from libgit2/cmn/branch-iterator
branch: move from foreach to an iterator
2013-11-05 06:55:16 -08:00
nulltoken
61080a959d Fix leaks 2013-11-05 15:10:02 +01:00
Vicent Martí
ffd040532a Merge pull request #1941 from libgit2/rb/preserve-iterator-error
Preserve error messages during file system iterator cleanup
2013-11-05 06:05:32 -08:00
Carlos Martín Nieto
8ec889a45f branch: move from foreach to an iterator
Create a git_branch_iterator type which is equivalent to the foreach but
lets us write loops instead of callbacks.

Since the introduction of git_reference_shorthand(), the added value of
passing the name is reduced.
2013-11-05 14:58:16 +01:00
Vicent Marti
1eab9f0e32 error: Simplify giterr_detach 2013-11-05 14:56:10 +01:00
nulltoken
e8162fd091 Propagate ELOCKED error when updating the config 2013-11-05 14:03:51 +01:00
Edward Thomson
1d3a8aeb4b move mode_t to filebuf_open instead of _commit 2013-11-04 22:33:05 -05:00
Edward Thomson
f966acd133 Take umask into account in filebuf_commit 2013-11-04 22:32:50 -05:00
Ben Straub
ac72051afa Fix ssh.c compile 2013-11-04 19:09:30 -08:00
Russell Belfer
3b259cbd1a Preserve file error in iterator
When the filesystem iterator encounters an error with a file, it
returns the error but because of the cleanup code, it was in some
cases erasing the error message.  This uses the giterr_detach API
to make sure that the actual error message is restored after the
cleanup code has been run.
2013-11-04 15:47:35 -08:00
Russell Belfer
d6c6016966 Add giterr_detach API to get and clear error
There are a number of cases where it is convenient to be able to
fetch and "claim" the current error string, clearing the error.
This is helpful when you need to call some code that may alter
the error and you want to restore it later on and/or report it via
some other mechanism.
2013-11-04 15:45:31 -08:00
Vicent Martí
0e1115d287 Merge pull request #1939 from ethomson/readwrite_odb
Allow backend consumers to specify file mode
2013-11-04 12:16:14 -08:00
Ben Straub
16bffd1c26 Unescape url-encoded usernames and passwords 2013-11-04 12:04:17 -08:00
Edward Thomson
dd64c71c26 Allow backend consumers to specify file mode 2013-11-04 14:50:25 -05:00
Ben Straub
c227c173b8 Use http_parser_parse_url to parse urls 2013-11-04 11:42:14 -08:00
Russell Belfer
fb6b0e019e Merge pull request #1317 from libgit2/blame
Blame Canada
2013-11-04 10:44:59 -08:00
Vicent Martí
44acdd1f9a Merge pull request #1937 from scunz/checkout_assert
Don't assert in git_checkout_tree
2013-11-04 08:09:58 -08:00
Vicent Martí
5a0b88036f Merge pull request #1929 from libgit2/rb/misc-diff-fixes
Fix some observed problems with incorrect diffs
2013-11-04 08:05:55 -08:00
Carlos Martín Nieto
a7a64d2cad remote: don't write too much when dealing with multivars
We used to move `data_start` forward, which is wrong as that needs to
point to the beginning of the buffer in order to perform size
calculations.

Introduce a `write_start` variable which indicates where we should start
writing from, which is what the `data_start` was being wrongly reused to
be.
2013-11-02 18:54:55 +01:00
Sascha Cunz
7b3959b227 Checkout: git_checkout_head is git_checkout_tree without a treeish
The last commit taught git_checkout_tree to actually do something
meaningfull, when treeish was NULL. This lets us rewrite
git_checkout_head to simply call git_checkout_tree without giving it a
treeish.
2013-11-02 03:45:32 +00:00
Sascha Cunz
352214416c Checkout: Don't assert if treeish is NULL
In git_checkout_tree, the first check tests if either repo or treeish is
NULL and says that eithor of them has to have a valid value. But there
is no code to handle the treeish == NULL case.

So, do something meaningful in that case: use HEAD instead.
2013-11-02 03:43:34 +00:00
Sascha Cunz
10749f6ca2 Checkout: Unifiy const-ness of opts parameter
Since all 3 checkout APIs perform the same operation with the options,
all of them should use the same const-ness.
2013-11-02 03:20:05 +00:00
Ben Straub
56c1cda28a Clarify parsing issues and errors 2013-11-01 19:22:43 -07:00
Ben Straub
7e0359084e Streamline url-parsing logic. 2013-11-01 15:29:25 -07: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
Carlos Martín Nieto
a7382aa28c remote: give up after 256 failures to find a common object
This avoids sending our whole history bit by bit to the remote in cases
where there is no common history, just to give up in the end.

The number comes from the canonical implementation.
2013-11-01 22:47:06 +01:00
Carlos Martín Nieto
2f03050f4f remote: download HEAD when no refspecs are given
The correct behaviour when a remote has no refspecs (e.g. a URL from the
command-line) is to download the remote's HEAD. Let's do that.

This fixes #1261.
2013-11-01 22:47:06 +01:00
Edward Thomson
c2408a698a preserve windows error numbers as well 2013-11-01 17:27:07 -04:00
Russell Belfer
3e57069e82 Fix --assume-unchanged support
This was never really working right because we were checking the
wrong flag and not checking it in all the places that we need to
be checking it.  I finally got around to writing a test and adding
actual support for it.
2013-11-01 13:49:43 -07:00
Russell Belfer
e7c85120ea More tests and fixed for merging reversed diffs
There were a lot more cases to deal with to make sure that our
merged (i.e. workdir-to-tree-to-index) diffs were matching the
output of core Git.
2013-11-01 11:39:37 -07:00
Russell Belfer
a5c16f3cfb Add git_diff_options_init helper
Sometimes the static initializer for git_diff_options cannot be
used and since setting them to all zeroes doesn't actually work
quite right, this adds a new helper for that situation.

This also adds an explicit new value to the submodule settings
options to be used when those enums need static initialization.
2013-11-01 10:20:51 -07:00
Russell Belfer
8e5a8ef86f Convert git_index_read to have a "force" flag
This is a little more intuitive than the turned-around option that
I originally wrote.
2013-11-01 10:20:51 -07:00
Russell Belfer
4bf630b6ba Make diff and status perform soft index reload
This changes `git_index_read` to have two modes - a hard index
reload that always resets the index to match the on-disk data
(which was the old behavior) and a soft index reload that uses
the timestamp / file size information and only replaces the index
data if the file on disk has been modified.

This then updates the git_status code to do a soft reload unless
the new GIT_STATUS_OPT_NO_REFRESH flag is passed in.

This also changes the behavior of the git_diff functions that use
the index so that when an index is not explicitly passed in (i.e.
when the functions call git_repository_index for you), they will
also do a soft reload for you.

This intentionally breaks the file signature of git_index_read
because there has been some confusion about the behavior previously
and it seems like all existing uses of the API should probably be
examined to select the desired behavior.
2013-11-01 10:20:51 -07:00
Russell Belfer
3940310e29 Fix some of the glaring errors in GIT_DIFF_REVERSE
These changes fix the basic problem with GIT_DIFF_REVERSE being
broken for text diffs.  The reversed diff entries were getting
added to the git_diff correctly, but some of the metadata was kept
incorrectly in a way that prevented the text diffs from being
generated correctly.  Once I fixed that, it became clear that it
was not possible to merge reversed diffs correctly.  This has a
first pass at fixing that problem.  We probably need more tests
to make sure that is really fixed thoroughly.
2013-11-01 10:20:51 -07:00
Russell Belfer
948f00b4e7 Merge pull request #1933 from libgit2/vmg/gcc-warnings
Warnings for Windows x64 (MSVC) and GCC on Linux
2013-11-01 09:38:03 -07:00
Vicent Marti
0bfa732342 iconv: Do not fake an API when iconv is not available 2013-11-01 17:36:09 +01:00
Vicent Marti
95352b7058 checkout: Remove unused vector 2013-11-01 17:36:09 +01:00
Vicent Marti
7334238696 array: Wrap array_alloc as a single statement 2013-11-01 17:36:09 +01:00
Vicent Marti
51a3dfb595 pack: __object_header always returns unsigned values 2013-11-01 17:36:09 +01:00
Linquize
3343b5ffd3 Fix warning on win64 2013-11-01 17:36:04 +01:00
Vicent Martí
ac5e507cec Merge pull request #1918 from libgit2/cmn/indexer-naming
indexer: remove the stream infix
2013-11-01 09:31:52 -07:00
Vicent Marti
b22593fb64 config_file: Style fixes 2013-11-01 17:30:41 +01:00
Vicent Marti
653ec420f9 Merge remote-tracking branch 'drodriguez/fix-remote-save' into development 2013-11-01 17:25:32 +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
a71331ebc4 Fix memory leaks. 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
Ben Straub
048f837b2f Prevent another segfault from bad URL 2013-10-31 13:30:22 -07:00
Ben Straub
151b321898 Prevent segfault with a badly-formed URL 2013-10-31 13:16:04 -07:00
Ben Straub
29b77446b7 Initialize variables 2013-10-30 15:38:52 -07:00
Vicent Martí
cc7453417f Merge pull request #1919 from libgit2/cmn/multi-ack-detailed
protocol: basic support for multi_ack_detailed
2013-10-30 09:27:36 -07:00
Carlos Martín Nieto
1d37da3392 merge: any non-zero return from the user is an error
This fixes #1703.
2013-10-30 16:25:49 +01:00
Carlos Martín Nieto
2f8c481cc0 protocol: basic support for multi_ack_detailed
This tells the server that we speak it, but we don't make use of its
extra information to determine if there's a better place to stop
negotiating.

In a somewhat-related change, reorder the capabilities so we ask for
them in the same order as git does.

Also take this opportunity to factor out a fairly-indented portion of
the negotiation logic.
2013-10-30 16:20:42 +01:00
Carlos Martín Nieto
a6154f2183 indexer: remove the stream infix
It was there to keep it apart from the one which read in from a file on
disk. This other indexer does not exist anymore, so there is no need for
anything other than git_indexer to refer to it.

While here, rename _add() function to _append() and _finalize() to
_commit(). The former change is cosmetic, while the latter avoids
talking about "finalizing", which OO languages use to mean something
completely different.
2013-10-30 15:00:05 +01:00
Vicent Marti
04e0c2b24d pack-objects: Depth can be negative 2013-10-30 14:00:44 +01:00
Ben Straub
7dcb1c4525 Adjust for diff API changes 2013-10-28 11:21:23 -07:00
Ben Straub
42c8f8f807 Merge remote-tracking branch 'libgit2/development' into blame 2013-10-28 11:04:58 -07:00
Vicent Martí
5c50f22a93 Merge pull request #1891 from libgit2/cmn/fix-thin-packs
Add support for thin packs
2013-10-28 09:25:44 -07:00
Vicent Martí
5565f3cda8 Merge pull request #1904 from libgit2/cmn/ssh-naming
Rename the ssh credentials
2013-10-28 07:04:58 -07:00
Ben Straub
8f4a8b096b Merge pull request #1802 from libgit2/cmn/reflog-backend
Make reflog part of refdb
2013-10-28 06:20:28 -07:00
Ben Straub
a7d28f40a2 ❤️ bool 2013-10-28 05:22:37 -07:00
Ben Straub
7f6db0ad12 Mmmm, GIT_FLEX_ARRAY 2013-10-28 05:19:30 -07:00
Ben Straub
ba02079f2d Avoid temporary object in lookup routine 2013-10-28 05:01:33 -07: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
Edward Thomson
df9fc82e97 Use two calls to set two headers 2013-10-25 13:33:42 -04:00
Carlos Martín Nieto
5cb136705d transport: let the progress output return an error
There are any number of issues that can come up in the progress
callback, and we should let the user cancel at that point as well.
2013-10-23 15:45:29 +02:00
Carlos Martín Nieto
ab46b1d8eb indexer: include the delta stats
The user is unable to derive the number of deltas in the pack, as that
would require them to capture the stats exactly in the moment between
download and final processing, which is abstracted away in the fetch.

Capture these numbers for the user and expose them in the progress
struct. The clone and fetch examples now also present this information
to the user.
2013-10-23 15:08:18 +02:00
Carlos Martín Nieto
70a8c78f36 Rename the ssh credentials
The names from libssh2 are somewhat obtuse for us. We can simplify the
usual key/passphrase credential's name, as well as make clearer what the
custom signature function is.
2013-10-23 12:08:54 +02:00
Vicent Martí
1c74686e05 Merge pull request #1897 from libgit2/split-patch-from-diff
RFC: Proposed reworking of diff APIs
2013-10-22 11:55:54 -07:00
Vicent Marti
98fec8a937 Implement git_odb_object_dup 2013-10-22 16:06:12 +02:00
Russell Belfer
5de4ec8104 Implement patience and minimal diff flags
It seems that to implement these options, we just have to pass
the appropriate flags through to the libxdiff code taken from
core git.  So let's do it (and add a test).
2013-10-21 15:36:38 -07:00
Russell Belfer
623460ab13 Fix warnings for win64 2013-10-21 14:16:53 -07:00
Russell Belfer
3b5f795446 Create git_diff_line and extend git_diff_hunk
Instead of having functions with so very many parameters to pass
hunk and line data, this takes the existing git_diff_hunk struct
and extends it with more hunk data, plus adds a git_diff_line.
Those structs are used to pass back hunk and line data instead of
the old APIs that took tons of parameters.

Some work that was previously only being done for git_diff_patch
creation (scanning the diff content for exact line counts) is now
done for all callbacks, but the performance difference should not
be noticable.
2013-10-21 13:42:42 -07:00
Edward Thomson
2648dc1a06 Allowed credential types should be a bitfield 2013-10-21 14:02:36 -05:00
Russell Belfer
74a627f045 Tweak to git_diff_delta structure for nfiles
While the base git_diff_delta structure always contains two files,
when we introduce conflict data, it will be helpful to have an
indicator when an additional file is involved.
2013-10-21 09:07:19 -07:00
Edward Thomson
c929d6b727 Move path prefixed help to path.h 2013-10-16 16:20:24 -04:00
Edward Thomson
7fa73de163 Move functions in checkout_conflicts to checkout.c
It seemed exceptionally silly to have a split there
where no split needed to be.
2013-10-16 16:20:21 -04:00
Edward Thomson
216f97e4f6 Two-step conflict checkout (load / perform)
Move conflict handling into two steps: load the conflicts and
then apply the conflicts.  This is more compatible with the
existing checkout implementation and makes progress reporting
more sane.
2013-10-16 16:20:19 -04:00
Edward Thomson
cfae7f85fb Honor UPDATE_ONLY bit when checking out conflicts 2013-10-16 16:20:18 -04:00
Edward Thomson
6f8cc7bb6a Fix warning, fix memory leak 2013-10-16 16:20:16 -04:00
Edward Thomson
e47f859db9 Don't overwrite ~ files checking out conflicts
If a D/F conflict or rename 2->1 conflict occurs,
we write the file sides as filename~branchname.  If
a file with that name already exists in the working
directory, write as filename~branchname_0 instead.
(Incrementing 0 until a unique filename is found.)
2013-10-16 16:20:14 -04:00
Edward Thomson
fc36800ecd Get rid of some quick hacks 2013-10-16 16:20:12 -04:00
Edward Thomson
96d799aa18 checkout rename conflicts
rename conflict tests for checkout conflicts, don't suffix filenames
when checking out with USE_OURS or USE_THEIRS
2013-10-16 16:20:10 -04:00
Edward Thomson
629b661caa checkout (from index) can write conflicts 2013-10-16 16:20:06 -04:00
Russell Belfer
10672e3e45 Diff API cleanup
This lays groundwork for separating formatting options from diff
creation options.  This groups the formatting flags separately
from the diff list creation flags and reorders the options.  This
also tweaks some APIs to further separate code that uses patches
from code that just looks at git_diffs.
2013-10-15 15:10:07 -07:00
Russell Belfer
3ff1d12373 Rename diff objects and split patch.h
This makes no functional change to diff but renames a couple of
the objects and splits the new git_patch (formerly git_diff_patch)
into a new header file.
2013-10-11 14:51:54 -07:00
Vicent Martí
2c2b0ebb4a Merge pull request #1562 from libgit2/cmn/refs-namespace-lookup
Provide the user with a more useful error code when a looking up a reference which name points to a namepace
2013-10-11 09:47:05 -07:00
Carlos Martín Nieto
893055f22e indexer: clearer stats for thin packs
Don't increase the number of total objects, as it can produce
suprising progress output. The only addition compared to pre-thin is
the addition of local_objects to allow an output similar to git's
"completed with %d local objects".
2013-10-11 17:26:20 +02:00
Carlos Martín Nieto
7c9f5bec51 futils: return GIT_ENOTFOUND when trying to read a directory
This lets the reference code return not-found when the user asks to
look up a reference when in fact they pass a namespace.
2013-10-11 16:29:59 +02:00
Ben Straub
364d800b01 Move flag dependencies into docs and code. 2013-10-10 14:53:07 -07:00
Ben Straub
c1ca2b67e1 Include signatures in blame hunks 2013-10-10 14:30:05 -07:00
Russell Belfer
743531372a After iconv init reset ref normalize error
The iconv init was accidentally clearing the default error state
during reference normalization. This resets so that normalization
errors will be detected correctly.
2013-10-09 11:57:03 -07:00
Vicent Martí
95c148b2c7 Merge pull request #1886 from libgit2/precompose-utf8
Add support for core.precomposeunicode on Mac
2013-10-08 17:03:12 -07:00
Russell Belfer
867f7c9b33 Rename new fn to git_repository_reinit_filesystem 2013-10-08 16:59:59 -07:00
Russell Belfer
92dac97586 Make reference lookups apply precomposeunicode
Before these changes, looking up a reference would return the
same precomposed or decomposed form of the reference name that
was used to look it up, so on MacOS which ignores the difference
between the two, a single reference could be looked up either way
and git_reference_name would return the form of the name that was
used to look it up!  This change makes lookup always return the
precomposed name if core.precomposeunicode is set regardless of
which version was used to look it up.  The reference iterator was
already returning the precomposed form from earlier work.

This also updates the CMakeLists.txt rules for enabling iconv
usage because the clar tests for this code were actually not being
activated properly with the old version.

Finally, this moves git_repository_reset_filesystem from include/
git2/repository.h to include/git2/sys/repository.h since it is not
really a function that normal library users should have to think
about very often.
2013-10-08 16:35:57 -07:00
Ben Straub
3dc3c723da Combine WinHTTP API calls 2013-10-08 15:52:37 -07:00
Ben Straub
a58eecd436 WinHTTP: set Accept header for POSTs 2013-10-08 13:40:52 -07:00
Russell Belfer
14997dc5f6 More filemode cleanups for FAT on MacOS
This cleans up some additional issues.  The main change is that
on a filesystem that doesn't support mode bits, libgit2 will now
create new blobs with GIT_FILEMODE_BLOB always instead of being
at the mercy to the filesystem driver to report executable or not.
This means that if "core.filemode" lies and claims that filemode
is not supported, then we will ignore the executable bit from the
filesystem.  Previously we would have allowed it.

This adds an option to the new git_repository_reset_filesystem to
recurse through submodules if desired.  There may be other types
of APIs that would like a "recurse submodules" option, but this
one is particularly useful.

This also has a number of cleanups, etc., for related things
including trying to give better error messages when problems come
up from the filesystem.  For example, the FAT filesystem driver on
MacOS appears to return errno EINVAL if you attempt to write a
filename with invalid UTF-8 in it.  We try to capture that with a
better error message now.
2013-10-08 12:45:43 -07:00
Carlos Martín Nieto
7fb6eb278b indexer: inject one base at a time
There may be multiple deltas referencing the same base as well as OFS
deltas which rely on a thin delta. Deal with both at the same time by
injecting a single object and going back up to the main
delta-resolving loop.
2013-10-08 11:54:50 +02:00
Carlos Martín Nieto
13f670a5d9 tree: allow retrieval of raw attributes
When a tool needs to recreate the tree object (for example an
interface to another VCS), it needs to use the raw attributes,
forgoing any normalization.
2013-10-08 10:07:31 +02:00
Ben Straub
2266144897 Don't use git_atomic as an integer 2013-10-04 19:35:32 -07:00
Philip Kelley
cdc95a0d93 Use InterlockedCompareExchange for the lock 2013-10-04 19:34:08 -07:00
Ben Straub
e411b74ebd Posix synchronized init, prototype win32 version 2013-10-04 19:33:48 -07:00
Russell Belfer
5173ea921d Add git_repository_reset_filesystem and fix tests
When a repository is transferred from one file system to another,
many of the config settings that represent the properties of the
file system may be wrong.  This adds a new public API that will
refresh the config settings of the repository to account for the
change of file system.  This doesn't do a full "reinitialize" and
operates on a existing git_repository object refreshing the config
when done.

This commit then makes use of the new API in clar as each test
repository is set up.

This commit also has a number of other clar test fixes where we
were making assumptions about the type of filesystem, either based
on outdated config data or based on the OS instead of the FS.
2013-10-04 16:32:16 -07:00
nulltoken
da7b78fa44 index: Make _read() cope with index file creation 2013-10-04 15:54:36 +02:00
Carlos Martín Nieto
b4342b116d net: advertise our support for fixing thin packs 2013-10-04 15:26:43 +02:00
Carlos Martín Nieto
0b33fca03e indexer: fix thin packs
When given an ODB from which to read objects, the indexer will attempt
to inject the missing bases at the end of the pack and update the
header and trailer to reflect the new contents.
2013-10-04 15:26:41 +02:00
Carlos Martín Nieto
51e82492ef pack: move the object header function here 2013-10-04 10:18:20 +02:00
Carlos Martín Nieto
cf0582b43c indexer: do multiple passes over the delta list
Though unusual, a packfile may contain a delta whose base is a delta
that comes later. In order index such a packfile, we must not give up
on the first failure to resolve a delta, but keep it around.

If there is a pass which makes no progress, this indicates that the
packfile is broken, so fail accordingly.
2013-10-04 10:18:20 +02:00
Russell Belfer
840fb4fc43 Update repo init with fewer platform assumptions
The repo init code was assuming Windows == no filemode, and
Mac or Windows == no case sensitivity.  Those assumptions are not
consistently true depending on the mounted file system.  This is a
first step to removing those assumptions.  It focuses on the repo
init code and the tests of that code.  There are still many other
tests that are broken when those assumptions don't hold true, but
this clears up one area of the code.

Also, this moves the core.precomposeunicode logic to be closer to
the current logic in core Git where it will be set to true on any
filesystem where composed unicode is decomposed when read back.
2013-10-03 14:42:37 -07:00
Russell Belfer
af302acaee Clean up annoying warnings
The indexer code was generating warnings on Windows 64-bit.  I
looked closely at the logic and was able to simplify it a bit.

Also this fixes some other Windows and Linux warnings.
2013-10-03 10:45:04 -07:00
Russell Belfer
618b7689e1 Wrap iconv stuff and write tests
This adds a simple wrapper around the iconv APIs and uses it
instead of the old code that was inlining the iconv stuff.  This
makes it possible for me to test the iconv logic in isolation.
A "no iconv" version of the API was defined with macros so that
I could have fewer ifdefs in the code itself.
2013-10-03 10:44:13 -07:00
Russell Belfer
d0849f830f Simplify git_path_is_empty_dir implementation
This simplifies git_path_is_empty_dir on both Windows (getting rid
of git_buf allocation inside the function) and other platforms (by
just using git_path_direach), and adds tests for the function, and
uses the function to simplify some existing tests.
2013-10-03 10:44:13 -07:00
Russell Belfer
219d345732 Initial iconv hookup for precomposed unicode
This hooks up git_path_direach and git_path_dirload so that they
will take a flag indicating if directory entry names should be
tested and converted from decomposed unicode to precomposed form.
This code will only come into play on the Apple platform and even
then, only when certain types of filesystems are used.

This involved adding a flag to these functions which involved
changing a lot of places in the code.

This was an opportunity to do a bit of code cleanup here and there,
for example, getting rid of the git_futils_cleanupdir_r function in
favor of a simple flag to git_futils_rmdir_r to not remove the top
level entry.  That ended up adding depth tracking during rmdir_r
which led to a safety check for infinite directory recursion.  Yay.

This hasn't actually been tested on the Mac filesystems where the
issue occurs.  I still need to get test environment for that.
2013-10-03 10:44:13 -07:00
Russell Belfer
2fe54afa2a Put hooks in place for precompose in dirload fn
This doesn't actual do string precompose but it puts the hooks in
place into the iterators and the git_path_dirload function so that
the actual precompose work is ready to go.
2013-10-03 10:44:13 -07:00
Russell Belfer
6b7991e264 Add check if we need to precompose unicode on Mac
This adds initialization of core.precomposeunicode to repo init
on Mac.  This is necessary because when a Mac accesses a repo on
a VFAT or SAMBA file system, it will return directory entries in
decomposed unicode even if the filesystem entry is precomposed.

This also removes caching of a number of repo properties from the
repo init pipeline because these are properties of the specific
filesystem on which the repo is created, not of the system as a
whole.
2013-10-03 10:44:13 -07:00
Vicent Martí
146b4d1c5f Merge pull request #1888 from jamill/network_cancellation
network cancellation improvements
2013-10-03 08:18:41 -07:00
Jameson Miller
7baa7631ea Style tweaks and changes for code review feedback 2013-10-03 09:51:21 -04:00
Ben Straub
fc1f7d4f15 Merge branch 'development' into blame
Conflicts:
	include/git2.h
2013-10-03 06:20:20 -07:00
Vicent Martí
ab13687662 Merge pull request #1887 from libgit2/ntk/topic/git_message_raw
commit: Introduce git_commit_message_raw()
2013-10-03 04:36:29 -07:00
nulltoken
598f069b99 commit: Introduce git_commit_message_raw() 2013-10-03 07:59:55 +02:00
Ben Straub
41a6de289f HTTP: handle "relative" redirects 2013-10-02 14:45:57 -07:00
Jameson Miller
5b18822545 Support cancellation in push operation
This commit adds cancellation for the push operation. This work consists of:

1) Support cancellation during push operation
    - During object counting phase
    - During network transfer phase
        - Propagate GIT_EUSER error code out to caller
2) Improve cancellation support during fetch
    - Handle cancellation request during network transfer phase
    - Clear error string when cancelled during indexing
3) Fix error handling in git_smart__download_pack

Cancellation during push is still only handled in the pack building and
network transfer stages of push (and not during packbuilding).
2013-10-02 15:12:44 -04: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
0174794a95 reflog: bring _append and _drop back to the frontend
These functions act purely on the reflog data structure.
2013-10-02 06:53:24 +02:00
Carlos Martín Nieto
d274deea23 reflog: add a convenience append function
Provide a function that reads a reflog, performs an append and writes back to the
backend in one call.
2013-10-02 06:53:24 +02:00
Carlos Martín Nieto
b976f3c2c2 reflog: move the reflog implementation into refdb_fs
References and their logs are logically coupled, let's make it so in
the code by moving the fs-based reflog implementation to live next to
the fs-based refs one.

As part of the change, make the function take names rather than
references, as only the names are relevant when looking up and
handling reflogs.
2013-10-02 06:53:24 +02:00
Carlos Martín Nieto
fdc7e5e35e clone: bring back NULL as defaults
This wasremoved as part of the large culling a few commits ago.
2013-10-02 06:42:27 +02:00
Carlos Martín Nieto
c833893c64 clone: re-allow using a custom remote name
This is a small thing that by itself doesn't quite justify making the
user use clone_into.
2013-10-02 06:42:26 +02:00
Carlos Martín Nieto
eec1c1fe1e clone: const-ify checkout options
The removal of many options which lead to the direct usage of the
user's checkout options means we should make sure they remain const.
2013-10-02 06:42:26 +02:00
Carlos Martín Nieto
b9bf5d701d clone: re-add a way to ignore certificate errors
This used to be done via transport flags, which was removed in a
previous commit.
2013-10-02 06:42:26 +02:00
Carlos Martín Nieto
6ac15eff6d clone: remove more options from basic clone
The basic clone function is there to make it easy to create a "normal"
clone. Remove a bunch of options that are about changing the remote's
configuration.
2013-10-02 06:42:26 +02:00
Carlos Martín Nieto
e3a92f0dfc clone: implement git_clone on top of git_clone_into
Unify the code bases.
2013-10-02 06:41:42 +02:00
Carlos Martín Nieto
c8dbec4803 clone: remove the autotag option
Downloading all tags is part of what makes it a clone instead of
simply a fetch.
2013-10-02 06:41:42 +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
d19870d947 clone: implement git_clone_into
This allows you to set up the repository and remote as you which to
have them before performing the clone operation.
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
Philip Kelley
8378695671 Add git_transport_register, git_transport_unregister 2013-10-01 16:49:41 -04:00
Ben Straub
816d28e7bc Mark git__timer as inline on OSX 2013-10-01 12:56:47 -07:00
Vicent Martí
c655aa5209 Merge pull request #1882 from linquize/config-subsection-fix
Config subsection name should allow to have ']' and '\\' should allow to escape any characters
2013-10-01 05:54:54 -07:00
Linquize
566dd8cec0 Config subsection name should allow to have ']' and '\\' should allow to escape any characters 2013-10-01 09:56:17 +08:00
Vicent Martí
fba147631e Merge pull request #1879 from libgit2/redir-refactor
Redir refactor
2013-09-30 15:03:35 -07:00
Vicent Martí
a6884b6fc7 Merge pull request #1412 from jamill/push_progress
Initial Implementation of progress reports during push
2013-09-30 14:58:45 -07:00
Vicent Martí
9acde16266 Merge pull request #1881 from libgit2/ignore-submodules-in-stash
Never consider submodules for stashing
2013-09-30 14:57:48 -07:00
Vicent Martí
dc56fea7a3 Merge pull request #1878 from libgit2/ntk/fix/warnings
Fix x86/x64 size_t related warnings
2013-09-30 12:18:19 -07:00
Jameson Miller
b176ededb7 Initial Implementation of progress reports during push
This adds the basics of progress reporting during push. While progress
for all aspects of a push operation are not reported with this change,
it lays the foundation to add these later. Push progress reporting
can be improved in the future - and consumers of the API should
just get more accurate information at that point.

The main areas where this is lacking are:

1) packbuilding progress: does not report progress during deltafication,
   as this involves coordinating progress from multiple threads.

2) network progress: reports progress as objects and bytes are going
   to be written to the subtransport (instead of as client gets
   confirmation that they have been received by the server) and leaves
   out some of the bytes that are transfered as part of the push protocol.
   Basically, this reports the pack bytes that are written to the
   subtransport. It does not report the bytes sent on the wire that
   are received by the server. This should be a good estimate of
   progress (and an improvement over no progress).
2013-09-30 13:22:28 -04:00
nulltoken
d27a441dde commit: Trim message leading newlines
Fix libgit2/libgit2sharp#522
2013-09-30 11:33:58 +02:00
Justin Spahr-Summers
4fe0b0b34b Never consider submodules for stashing 2013-09-27 17:07:06 -07:00
Ben Straub
b59344bf83 Tighten up url-connection utility 2013-09-26 16:48:46 -07:00
Ben Straub
256961e45d WHOOPS 2013-09-26 16:36:05 -07:00
Ben Straub
1b02baf40b Adjust to new utility signature 2013-09-26 16:25:05 -07:00
Ben Straub
ea59f65977 Deploy gitno_connection_data into transport (winhttp)
...and have that call manage replaced memory in the output structure.
2013-09-26 16:20:30 -07:00
Ben Straub
83fbd36869 Deploy gitno_connection_data into transport 2013-09-26 15:58:41 -07:00
nulltoken
8a1e925dde Fix warnings 2013-09-26 20:44:43 +02:00
Ben Straub
f30d91ce48 Refactor URL handling to use library call 2013-09-26 11:03:27 -07:00
Ben Straub
8988688c47 Migrate redirect URL handling to common utility 2013-09-25 20:41:56 -07:00
Ben Straub
41dd999d12 Merge branch 'development' into blame 2013-09-25 14:47:32 -07:00
Ben Straub
49781a03f0 Blame: minor cleanup 2013-09-25 14:40:19 -07:00
Ben Straub
ac316e7438 Why are we disabling redirects? 2013-09-25 14:25:38 -07:00
Ben Straub
4a88eb20b9 Win32: handle http->https redirects 2013-09-25 12:13:09 -07:00
Vicent Martí
4dbdbf6489 Merge pull request #1871 from libgit2/cross-protocol-redirects-alt
Alternative fix for cross protocol redirects
2013-09-24 15:21:44 -07:00
Russell Belfer
46fbc88ee5 Prevent HTTPS to HTTP redirect 2013-09-24 14:50:06 -07:00
Russell Belfer
eb0ff13071 Disconnect path string to preserve after redirect
The subtransport path was relying on pointing to data owned by
the remote which meant that after a redirect, the updated path
was getting lost for future requests.  This updates the http
transport to strdup the path and maintain its own lifetime.

This also pulls responsibility for parsing the URL back into the
http transport and isolates the functions that parse and free that
connection data so that they can be reused between the initial
parsing and the redirect parsing.
2013-09-24 14:07:08 -07:00
Edward Thomson
5c3b8ef48b Ignore files that disappear while iterating
On occasion, files can disappear while we're iterating the
filesystem, between calls to readdir and stat.  Let's pretend
those didn't exist in the first place.
2013-09-24 14:52:58 -04:00
Ben Straub
c91444055a Properly parse urls that include protocol:// 2013-09-24 11:18:43 -07:00
Ben Straub
210d532526 Allow redirects to use same host 2013-09-24 11:18:36 -07:00
Vicent Martí
4a1b40159b Merge pull request #1865 from arrbee/various-cleanups
Various warning cleanup and minor fixes
2013-09-24 10:32:40 -07:00
Vicent Martí
5dc8513b29 Merge pull request #1864 from libgit2/minimize-regex-usage
Minimize regex usage
2013-09-24 10:30:43 -07:00
Russell Belfer
634f10f690 Fix incorrect return code in crlf filter
The git_buf_text_gather_stats call returns a boolean indicating if
the file looks like binary data.  That shouldn't be an error; it
should be used to skip CRLF processing though.
2013-09-24 10:11:20 -07:00
Edward Thomson
e3f3868a1c 'del' instead of 'delete' for the poor C++ users 2013-09-24 11:04:14 -04:00
Russell Belfer
00e859279e Clean up unnecessary git_buf_printf calls
This replaces some git_buf_printf calls with simple calls to
git_buf_put instead.  Also, it fixes a missing va_end inside
the git_buf_vprintf implementation.
2013-09-23 21:52:42 -07:00
Russell Belfer
713793133f Fix warnings on Windows 64-bit build 2013-09-23 21:41:52 -07:00
Russell Belfer
1ca3e49f88 Clean up newly introduced warnings
The attempt to "clean up warnings" seems to have introduced some
new warnings on compliant compilers.  This fixes those in a way
that I suspect will also be okay for the non-compliant compilers.

Also this fixes what appears to be an extra semicolon in the
repo initialization template dir handling (and as part of that
fix, handles the case where an error occurs correctly).
2013-09-23 21:41:43 -07:00