Commit Graph

9561 Commits

Author SHA1 Message Date
Carlos Martín Nieto
922496562b tree: use testrepo2 for the tree updater tests
This gives us trees with subdirectories, which the new test needs.
2016-05-19 15:21:26 +02:00
Carl Edquist
c8fb2e152a Fix comment for GIT_FILEMODE_LINK
0120000 is symbolic link, not commit
2016-05-18 16:00:01 -05:00
Edward Thomson
1b56cda114 Merge pull request #3770 from libgit2/cmn/tree-update
Add a method specifically for modifying trees
2016-05-18 11:30:02 -05:00
Carlos Martín Nieto
9464f9ebc1 Introduce a function to create a tree based on a different one
Instead of going through the usual steps of reading a tree recursively
into an index, modifying it and writing it back out as a tree, introduce
a function to perform simple updates more efficiently.

`git_tree_create_updated` avoids reading trees which are not modified
and supports upsert and delete operations. It is not as versatile as
modifying the index, but it makes some common operations much more
efficient.
2016-05-17 17:41:05 +02:00
Edward Thomson
c148533024 Merge pull request #3767 from pks-t/pks/misc-fixes
Misc fixes
2016-05-09 08:58:44 -05:00
Edward Thomson
6f02f198c8 Merge pull request #3773 from lucasderraugh/patch-1
Fix unused variable 'message' warning
2016-05-08 17:48:22 -05:00
Carlos Martín Nieto
17a93afa78 Merge pull request #3757 from johnhaley81/jh/fix-create-initial-commit
Fix `git_commit_create` for an initial commit
2016-05-06 18:44:37 +02:00
Lucas Derraugh
2527db872a Fix unused variable 'message' warning 2016-05-05 23:35:48 -04:00
John Haley
5785ae9b5e Fix initial commit test
`test_commit_commit__create_initial_commit_parent_not_current` was not correctly 
testing that `HEAD` was not changed. Now we grab the oid that it was pointing to
before the call to `git_commit_create` and the oid that it's pointing to afterwards
and compare those.
2016-05-04 11:15:56 -07:00
Carlos Martín Nieto
2e43a37bcb Merge pull request #3769 from libgit2/ethomson/rebase_inmemory_no_base
Rebase: rebase a branch with no merge base for in-memory
2016-05-04 19:05:38 +02:00
John Haley
4f22ccb979 Add tests for creating an initial commit 2016-05-03 13:32:32 -07:00
John Haley
225cb8809e Fix git_commit_create for an initial commit
When calling `git_commit_create` with an empty array of `parents` and `parent_count == 0` 
the call will segfault at https://github.com/libgit2/libgit2/blob/master/src/commit.c#L107 
when it's trying to compare `current_id` to a null parent oid. 

This just puts in a check to stop that segfault.
2016-05-03 13:32:32 -07:00
Edward Thomson
9a363d1b26 rebase: handle no common ancestor for inmemory 2016-05-03 15:29:50 -04:00
Edward Thomson
c7b4bbffcc rebase: test rebase (merge) w/ no common ancestor 2016-05-03 15:29:44 -04:00
Patrick Steinhardt
fe3057b4b9 diff: simplify code for handling empty dirs
When determining diffs between two iterators we may need to
recurse into an unmatched directory for the "new" iterator when
it is either a prefix to the current item of the "old" iterator
or when untracked/ignored changes are requested by the user and
the directory is untracked/ignored.

When advancing into the directory and no files are found, we will
get back `GIT_ENOTFOUND`. If so, we simply skip the directory,
handling resulting unmatched old items in the next iteration. The
other case of `iterator_advance_into` returning either
`GIT_NOERROR` or any other error but `GIT_ENOTFOUND` will be
handled by the caller, which will now either compare the first
directory entry of the "new" iterator in case of `GIT_ENOERROR`
or abort on other cases.

Improve readability of the code to make the above logic more
clear.
2016-05-03 18:19:20 +02:00
Edward Thomson
4d384d6bbe Merge pull request #3759 from libgit2/cmn/faster-header
odb: avoid inflating the full delta to read the header
2016-05-02 13:59:51 -04:00
Patrick Steinhardt
153fde5b43 delta-apply: fix sign extension
We compute offsets by executing `off |= (*delta++ << 24)` for
multiple constants, where `off` is of type `size_t` and `delta`
is of type `unsigned char`. The usual arithmetic conversions (see
ISO C89 §3.2.1.5 "Usual arithmetic conversions") kick in here,
causing us to promote both operands to `int` and then extending
the result to an `unsigned long` when OR'ing it with `off`.
The integer promotion to `int` may result in wrong size
calculations for big values.

Fix the issue by making the constants `unsigned long`, causing both
operands to be promoted to `unsigned long`.
2016-05-02 17:45:24 +02:00
Patrick Steinhardt
7f407710ef odb_loose: fix undefined behavior when computing size
An object's size is computed by reading the object header's size
field until the most significant bit is not set anymore. To get
the total size, we increase the shift on each iteration and add
the shifted value to the total size.

We read the current value into a variable of type `unsigned
char`, from which we then take all bits except the most
significant bit and shift the result. We will end up with a
maximum shift of 60, but this exceeds the width of the value's
type, resulting in undefined behavior.

Fix the issue by instead reading the values into a variable of
type `unsigned long`, which matches the required width. This is
equivalent to git.git, which uses an `unsigned long` as well.
2016-05-02 17:45:24 +02:00
Patrick Steinhardt
7b24c4fd48 checkout: set ignorecase=0 when config lookup fails
When `git_repository__cvar` fails we may end up with a
`ignorecase` value of `-1`. As we subsequently check if
`ignorecase` is non-zero, we may end up reporting that data
should be removed when in fact it should not.

Err on the safer side and set `ignorecase = 0` when
`git_repository__cvar` fails.
2016-05-02 17:45:24 +02:00
Patrick Steinhardt
fcd1b78601 merge_file: do not unnecessarily check ours/theirs for NULL
The `merge_file__xdiff` function checks if either `ours` or
`theirs` is `NULL`. The function is to be called with existing
files, though, and in fact already unconditionally dereferences
both pointers.

Remove the unnecessary check to silence warnings.
2016-05-02 17:45:23 +02:00
Carlos Martín Nieto
a97b769a0e odb: avoid inflating the full delta to read the header
When we read the header, we want to know the size and type of the
object. We're currently inflating the full delta in order to read the
first few bytes. This can mean hundreds of kB needlessly inflated for
large objects.

Instead use a packfile stream to read just enough so we can read the two
varints in the header and avoid inflating most of the delta.
2016-05-02 17:37:26 +02:00
Patrick Steinhardt
f80852af80 index: fix memory leak on error case 2016-05-02 14:30:14 +02:00
Carlos Martín Nieto
d24425fa8e Merge pull request #3764 from libgit2/ethomson/cmake_pc
cmake: include threading libraries in pkg-config
2016-04-29 18:34:03 +02:00
Edward Thomson
097b0761f1 cmake: include threading libraries in pkg-config
Include any required threading libraries in our `libgit2.pc`.
2016-04-29 10:19:11 -04:00
Carlos Martín Nieto
5e8ba35d44 Merge pull request #3763 from libgit2/ethomson/signature_from_buffer
Introduce `git_signature_from_buffer`
2016-04-29 10:36:01 +02:00
Edward Thomson
1e7fa834b5 Merge pull request #3760 from backhub/bug/openssl_read
Fix return value of openssl_read (infinite loop)
2016-04-28 22:32:20 -04:00
Edward Thomson
d383c39b3b Introduce git_signature_from_buffer
Allow users to construct a signature from the type of signature
lines that actually appear in commits.
2016-04-28 12:47:14 -04:00
Christian Schlack
568c5a9fc1 Fix style: no braces 2016-04-27 13:56:16 +02:00
Carlos Martín Nieto
88284dfb79 Merge pull request #3758 from libgit2/ethomson/annotated_commit_refs
Annotated commits: differentiate between the ref names and the description
2016-04-26 21:21:27 +02:00
Edward Thomson
d55923788c annotated_commit: provide refs and description
Differentiate between the ref_name used to create an annotated_commit
(that can subsequently be used to look up the reference) and the
description that we resolved this with (which _cannot_ be looked up).

The description is used for things like reflogs (and may be a ref name,
and ID something that we revparsed to get here), while the ref name must
actually be a reference name, and is used for things like rebase to
return to the initial branch.
2016-04-26 13:19:58 -04:00
Christian Schlack
4734c52ab2 Fix return value of openssl_read (infinite loop)
openssl_read should return -1 in case of error.

SSL_read returns values <= 0 in case of error.

A return value of 0 can lead to an infinite loop, so the return value
of ssl_set_error will be returned if SSL_read is not successful (analog
to openssl_write).
2016-04-26 18:04:03 +02:00
Edward Thomson
b3ffd8f638 rebase::abort: test we can abort rebase by revspec
Test that we can properly abort a rebase when it is initialized by a
revspec.  This ensures that we do not conflate revspecs and refnames.
2016-04-26 11:49:05 -04:00
Carlos Martín Nieto
cb2dfa46c8 Merge pull request #3755 from arthurschreiber/patch-9
Remove traces of `git_blob_create_fromchunks`
2016-04-26 13:40:03 +02:00
Arthur Schreiber
a3e379cb4e Remove traces of git_blob_create_fromchunks 2016-04-26 11:10:31 +02:00
Carlos Martín Nieto
9068704bd8 Merge pull request #3749 from arthurschreiber/arthur/add-git-reference-dup
Allow creating copies of `git_reference` objects.
2016-04-26 11:02:45 +02:00
Carlos Martín Nieto
c30955e0c0 Merge pull request #3748 from libgit2/ethomson/rebase_detached
Rebase improvements with IDs
2016-04-26 11:02:05 +02:00
Edward Thomson
b058297afa Merge pull request #3752 from libgit2/cmn/silly-tags
tag: ignore extra header fields
2016-04-25 09:45:27 -04:00
Carlos Martín Nieto
eb39284bab tag: ignore extra header fields
While no extra header fields are defined for tags, git accepts them by
ignoring them and continuing the search for the message. There are a few
tags like this in the wild which git parses just fine, so we should do
the same.
2016-04-25 12:18:32 +02:00
Arthur Schreiber
908f24fd13 Allow creating copies of git_reference objects. 2016-04-22 10:34:17 -07:00
Carlos Martín Nieto
512bd2c78f Merge pull request #3747 from libgit2/ethomson/warnings
 some warnings
2016-04-22 15:40:08 +02:00
Edward Thomson
1f84caf0c0 rebase: correctly finish rebasing detached heads
When rebasing with IDs, we do not return to the `branch`,
we remain in a detached HEAD state.
2016-04-21 18:19:05 -04:00
Edward Thomson
badc72838f rebase: handle detached HEADs in init
When `init`ing a rebase from a detached HEAD, be sure to remember
that we were in a detached HEAD state so that we can correctly
`abort` the object that we just created.
2016-04-21 18:19:05 -04:00
Edward Thomson
320f53cd6c rebase: test abort immediately after init
Instead of `open`ing a rebase and `abort`ing that, test that we can
`abort` a rebase that has just begun with `init`.
2016-04-21 18:19:05 -04:00
Edward Thomson
0bd7740173 clone test: annotate unused vars 2016-04-21 11:05:21 -04:00
Edward Thomson
375bb2fe60 transport: cast away constness for free 2016-04-21 11:02:31 -04:00
Edward Thomson
e0aed4bda3 stransport: pass proxy opts instead of char* 2016-04-21 11:01:09 -04:00
Edward Thomson
db22a91b86 iterator: ignore submodule in has_ended 2016-04-21 10:58:22 -04:00
Edward Thomson
1dc449105b Merge pull request #3110 from libgit2/cmn/proxy-config
Proxy configuration
2016-04-19 19:48:52 -04:00
Carlos Martín Nieto
2638df7711 CI: download the proxy jar also on mingw
We were downloading the jar from within an block which only runs for
MSVC. Move the download to the start of the test so it gets downloaded
for both.
2016-04-19 23:05:16 +02:00
Edward Thomson
95fbc81daf Merge pull request #3745 from libgit2/cmn/ignore-starstar
Improve star-star matching
2016-04-19 15:24:14 -04:00