Commit Graph

9892 Commits

Author SHA1 Message Date
Carlos Martín Nieto
0bd43371c2 vector, pqueue: add git_vector_reverse and git_pqueue_reverse
This is a convenience function to reverse the contents of a vector and a pqueue
in-place.

The pqueue function is useful in the case where we're treating it as a
LIFO queue.
2016-10-06 11:04:55 +02:00
Carlos Martín Nieto
6708618c10 revwalk: get closer to git
We had some home-grown logic to figure out which objects to show during
the revision walk, but it was rather inefficient, looking over the same
list multiple times to figure out when we had run out of interesting
commits. We now use the lists in a smarter way.

We also introduce the slop mechanism to determine when to stpo
looking. When we run out of interesting objects, we continue preparing
the walk for another 5 rounds in order to make it less likely that we
miss objects in situations with complex graphs.
2016-10-06 11:04:55 +02:00
Edward Thomson
565fb8dcd4 revwalk: introduce tests that hide old commits
Introduce some tests that show some commits, while hiding some commits
that have a timestamp older than the common ancestors of these two
commits.
2016-10-06 11:04:55 +02:00
Carlos Martín Nieto
e8ab13b3fd Merge pull request #3954 from libgit2/cmn/osx-ssh-key
Travis Mac SSH key issues
2016-10-05 23:46:02 +02:00
Carlos Martín Nieto
db357667bc travis: take the newer ssh-keygen format into account
The Mac machines have updated their SSH version and so the ssh-keygen
format has changed. Ask it for MD5, which is the one that is output as
hex.
2016-10-05 20:23:58 +02:00
Carlos Martín Nieto
94d565b957 cibuild: set -x
This lets us see the details of what we're doing instead of just seeing the
output of unknown commands in the build output.
2016-10-05 18:52:43 +02:00
Edward Thomson
9fbbb0eec5 Merge pull request #3931 from libgit2/ethomson/checkout_dont_calculate_oid_for_dirs
checkout: don't try to calculate oid for directories
2016-10-01 19:32:16 -05:00
Edward Thomson
955c99c214 checkout: don't try to calculate oid for directories
When trying to determine if we can safely overwrite an existing workdir
item, we may need to calculate the oid for the workdir item to determine
if its identical to the old side (and eligible for removal).

We previously did this regardless of the type of entry in the workdir;
if it was a directory, we would open(2) it and then try to read(2).
The read(2) of a directory fails on many platforms, so we would treat it
as if it were unmodified and continue to perform the checkout.

On FreeBSD, you _can_ read(2) a directory, so this pattern failed.  We
would calculate an oid from the data read and determine that the
directory was modified and would therefore generate a checkout conflict.

This reliance on read(2) is silly (and was most likely accidentally
giving us the behavior we wanted), we should be explicit about the
directory test.
2016-09-14 10:28:24 +01:00
Edward Thomson
89c332e41b Merge pull request #3929 from libgit2/vmg/time
time: Export `git_time_monotonic`
2016-09-13 16:16:20 +02:00
Vicent Marti
2749ff46d8 time: Export git_time_monotonic 2016-09-13 15:52:43 +02:00
Patrick Steinhardt
bba704adf7 Merge pull request #3925 from pks-t/pks/cmake-library-dirs
cmake: add curl library path
2016-09-09 08:45:33 +02:00
Edward Thomson
9ad07fc003 Merge pull request #3923 from libgit2/ethomson/diff-read-empty-binary
Read binary patches (with no binary data)
2016-09-06 10:43:21 -05:00
Patrick Steinhardt
46035d984f Merge pull request #3882 from pks-t/pks/fix-fetch-refspec-dst-parsing
refspec: do not set empty rhs for fetch refspecs
2016-09-06 11:21:29 +02:00
Edward Thomson
adedac5aba diff: treat binary patches with no data special
When creating and printing diffs, deal with binary deltas that have
binary data specially, versus diffs that have a binary file but lack the
actual binary data.
2016-09-05 12:26:47 -05:00
Patrick Steinhardt
528b2f7df8 cmake: add curl library path
The `PKG_CHECK_MODULES` function searches a pkg-config module and
then proceeds to set various variables containing information on
how to link to the library. In contrast to the `FIND_PACKAGE`
function, the library path set by `PKG_CHECK_MODULES` will not
necessarily contain linking instructions with a complete path to
the library, though. So when a library is not installed in a
standard location, the linker might later fail due to being
unable to locate it.

While we already honor this when configuring libssh2 by adding
`LIBSSH2_LIBRARY_DIRS` to the link directories, we fail to do so
for libcurl, preventing us to build libgit2 on e.g. FreeBSD. Fix
the issue by adding the curl library directory to the linker
search path.
2016-09-05 13:24:07 +02:00
Edward Thomson
f4e3dae75f diff_print: change test for skipping binary printing
Instead of skipping printing a binary diff when there is no data, skip
printing when we have a status of `UNMODIFIED`.  This is more in-line
with our internal data model and allows us to expand the notion of
binary data.

In the future, there may have no data because the files were unmodified
(there was no data to produce) or it may have no data because there was
no data given to us in a patch.  We want to treat these cases
separately.
2016-09-02 11:26:16 -05:00
Edward Thomson
4bfd7c63fc patch: error on diff callback failure 2016-09-02 11:22:33 -05:00
Edward Thomson
ce54e77c70 Merge pull request #3922 from pks-t/pks/diff-only-load-binaries-when-requested
patch_generate: only calculate binary diffs if requested
2016-09-02 08:50:08 -05:00
Patrick Steinhardt
4b34f687bd patch_generate: only calculate binary diffs if requested
When generating diffs for binary files, we load and decompress
the blobs in order to generate the actual diff, which can be very
costly. While we cannot avoid this for the case when we are
called with the `GIT_DIFF_SHOW_BINARY` flag, we do not have to
load the blobs in the case where this flag is not set, as the
caller is expected to have no interest in the actual content of
binary files.

Fix the issue by only generating a binary diff when the caller is
actually interested in the diff. As libgit2 uses heuristics to
determine that a blob contains binary data by inspecting its size
without loading from the ODB, this saves us quite some time when
diffing in a repository with binary files.
2016-09-01 15:14:25 +02:00
Carlos Martín Nieto
40b08124f2 Merge pull request #3915 from pks-t/pks/index-collision-test-leak
tests: index: do not re-allocate index
2016-08-30 12:11:02 +02:00
Patrick Steinhardt
a08e88259f Merge pull request #3907 from steffhip/git_checkout_tree-fix 2016-08-30 08:22:49 +02:00
Stefan Huber
88cfe61497 git_checkout_tree options fix
According to the reference the git_checkout_tree and git_checkout_head
functions should accept NULL in the opts field

This was broken since the opts field was dereferenced and thus lead to a
crash.
2016-08-30 08:04:28 +02:00
Edward Thomson
dfd7957696 Merge pull request #3914 from pks-t/pks/libqgit2-binding-url
README: adjust URL to libqgit2 repository
2016-08-29 09:39:03 -05:00
Patrick Steinhardt
86e88534d6 tests: index: do not re-allocate index
Plug a memory leak caused by re-allocating a `git_index`
structure which has already been allocated by the test suite's
initializer.
2016-08-29 13:29:01 +02:00
Patrick Steinhardt
8044ee42f5 README: adjust URL to libqgit2 repository 2016-08-29 09:38:20 +02:00
Patrick Steinhardt
ace0d36be9 Merge pull request #3900 from pks-t/pks/http-close-substream-on-connect
transports: http: set substream as disconnected after closing
2016-08-29 09:29:34 +02:00
Richard Ipsum
452bf57cbe Make symbolic ref target validation optional
Introduce GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION option.
Setting this option to 0 allows
validation of a symbolic ref's target to be bypassed.
This option is enabled by default.

This mechanism is added primarily to address a discrepancy between git
behaviour and libgit2 behaviour, whereby the former allows the symbolic
ref target to carry an arbitrary string and the latter does not, so:

    $ git symbolic-ref refs/heads/foo bar
    $ cat .git/refs/heads/foo
    ref: bar

where as attempting the same via libgit2 raises an error:

    The given reference name 'bar' is not valid

this mechanism also allows those that might want to make use of
git's more lenient treatment of symbolic ref targets to do so.
2016-08-27 18:25:02 +01:00
Edward Thomson
5671e81fdd Merge pull request #3908 from libgit2/ethomson/patch_from_diff
Teach `git_patch_from_diff` about parsed diffs
2016-08-26 10:09:12 -05:00
Edward Thomson
b859faa61c Teach git_patch_from_diff about parsed diffs
Ensure that `git_patch_from_diff` can return the patch for parsed diffs,
not just generate a patch for a generated diff.
2016-08-24 09:08:57 -05:00
Patrick Steinhardt
c60210d367 Merge pull request #3904 from stinb/filesystem-iterator-double-free
filesystem_iterator: fixed double free on error
2016-08-24 08:28:49 +02:00
Jason Haslam
7a3f1de500 filesystem_iterator: fixed double free on error 2016-08-22 09:27:47 -06:00
Edward Thomson
c1b370e931 Merge pull request #3837 from novalis/dturner/indexv4
Support index v4
2016-08-17 09:24:44 -05:00
Edward Thomson
635a922274 Merge pull request #3895 from pks-t/pks/negate-basename-in-subdirs
ignore: allow unignoring basenames in subdirectories
2016-08-17 08:54:48 -05:00
Patrick Steinhardt
b1453601f9 transports: http: reset connected flag when closing transport 2016-08-17 11:41:30 +02:00
Patrick Steinhardt
c4cba4e96a transports: http: reset connected flag when re-connecting transport
When calling `http_connect` on a subtransport whose stream is already
connected, we first close the stream in case no keep-alive is in use.
When doing so, we do not reset the transport's connection state,
though. Usually, this will do no harm in case the subsequent connect
will succeed. But when the connection fails we are left with a
substransport which is tagged as connected but which has no valid
stream attached.

Fix the issue by resetting the subtransport's connected-state when
closing its stream in `http_connect`.
2016-08-17 11:41:22 +02:00
Patrick Steinhardt
fcb2c1c895 ignore: allow unignoring basenames in subdirectories
The .gitignore file allows for patterns which unignore previous
ignore patterns. When unignoring a previous pattern, there are
basically three cases how this is matched when no globbing is
used:

1. when a previous file has been ignored, it can be unignored by
   using its exact name, e.g.

   foo/bar
   !foo/bar

2. when a file in a subdirectory has been ignored, it can be
   unignored by using its basename, e.g.

   foo/bar
   !bar

3. when all files with a basename are ignored, a specific file
   can be unignored again by specifying its path in a
   subdirectory, e.g.

   bar
   !foo/bar

The first problem in libgit2 is that we did not correctly treat
the second case. While we verified that the negative pattern
matches the tail of the positive one, we did not verify if it
only matches the basename of the positive pattern. So e.g. we
would have also negated a pattern like

    foo/fruz_bar
    !bar

Furthermore, we did not check for the third case, where a
basename is being unignored in a certain subdirectory again.

Both issues are fixed with this commit.
2016-08-12 14:47:54 +02:00
David Turner
5625d86b99 index: support index v4
Support reading and writing index v4.  Index v4 uses a very simple
compression scheme for pathnames, but is otherwise similar to index v3.

Signed-off-by: David Turner <dturner@twitter.com>
2016-08-10 14:19:30 -04:00
David Turner
aeb5ee5ab5 varint: Add varint encoding/decoding
This code is ported from git.git

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Turner <dturner@twopensource.com>
2016-08-10 14:19:06 -04:00
Carlos Martín Nieto
26a8617d96 Merge pull request #3891 from pks-t/pks/stransport-memory-management-improvements
stransport memory management improvements
2016-08-09 14:34:55 +02:00
Edward Thomson
5961face15 Merge pull request #3893 from pks-t/pks/remove-unused-test-cb
tests: blob: remove unused callback function
2016-08-09 08:07:10 -04:00
Patrick Steinhardt
4006455f01 tests: blob: remove unused callback function 2016-08-09 10:09:23 +02:00
Patrick Steinhardt
b989514405 stransport: do not use git_stream_free on uninitialized stransport
When failing to initialize a new stransport stream, we try to
release already allocated memory by calling out to
`git_stream_free`, which in turn called out to the stream's
`free` function pointer. As we only initialize the function
pointer later on, this leads to a `NULL` pointer exception.

Furthermore, plug another memory leak when failing to create the
SSL context.
2016-08-09 08:38:54 +02:00
Carlos Martín Nieto
97e57e8770 Merge pull request #3887 from libgit2/ethomson/empty_blob
odb: only provide the empty tree
2016-08-08 15:13:59 +02:00
Edward Thomson
b47e79e2cd Merge pull request #3890 from pks-t/pks/stransport-static-linkage
stransport: make internal functions static
2016-08-08 08:42:32 -04:00
Patrick Steinhardt
067bf5dcc5 stransport: make internal functions static 2016-08-08 13:49:17 +02:00
Carlos Martín Nieto
0fd5a44dde Merge pull request #3888 from libgit2/ethomson/doc_diff_from_buffer
diff: document `git_diff_from_buffer`
2016-08-08 13:12:51 +02:00
Edward Thomson
9bc8c80ffa odb: actually insert the empty blob in tests 2016-08-05 20:34:19 -04:00
Edward Thomson
e2e7f31ad0 diff: document git_diff_from_buffer 2016-08-05 20:01:52 -04:00
Edward Thomson
becadafca8 odb: only provide the empty tree
Only provide the empty tree internally, which matches git's behavior.
If we provide the empty blob then any users trying to write it with
libgit2 would omit it from actually landing in the odb, which appear
to git proper as a broken repository (missing that object).
2016-08-05 19:30:56 -04:00
Edward Thomson
56bbdf9349 Merge pull request #3886 from libgit2/cmn/copypeertrust-null
SecureTransport: handle NULL trust on success
2016-08-05 14:23:29 -04:00