Commit Graph

2095 Commits

Author SHA1 Message Date
Edward Thomson
78b500bf59 Merge pull request #3850 from wildart/custom-tls
Enable https transport for custom TLS streams
2016-08-04 12:45:19 -04:00
Patrick Steinhardt
1eee631d11 refspec: do not set empty rhs for fetch refspecs
According to git-fetch(1), "[t]he colon can be omitted when <dst>
is empty." So according to git, the refspec "refs/heads/master"
is the same as the refspec "refs/heads/master:" when fetching
changes. When trying to fetch from a remote with a trailing
colon with libgit2, though, the fetch actually fails while it
works when the trailing colon is left out. So obviously, libgit2
does _not_ treat these two refspec formats the same for fetches.

The problem results from parsing refspecs, where the resulting
refspec has its destination set to an empty string in the case of
a trailing colon and to a `NULL` pointer in the case of no
trailing colon. When passing this to our DWIM machinery, the
empty string gets translated to "refs/heads/", which is simply
wrong.

Fix the problem by having the parsing machinery treat both cases
the same for fetch refspecs.
2016-08-04 13:54:19 +02:00
Patrick Steinhardt
f2cab0a6fa clar: fix parsing of test suite prefixes
When passing in a specific suite which should be executed by clar
via `-stest::suite`, we try to parse this string and then include
all tests contained in this suite. This also includes all tests
in sub-suites, e.g. 'test::suite::foo'.

In the case where multiple suites start with the same _string_,
for example 'test::foo' and 'test::foobar', we fail to
distinguish this correctly. When passing in `-stest::foobar`,
we wrongly determine that 'test::foo' is a prefix and try to
execute all of its matching functions. But as no function
will now match 'test::foobar', we simply execute nothing.

To fix this, we instead have to check if the prefix is an actual
suite prefix as opposed to a simple string prefix. We do so by by
inspecting if the first two characters trailing the prefix are
our suite delimiters '::', and only consider the filter as
matching in this case.
2016-08-04 11:49:39 +02:00
Edward Thomson
498d0801a1 tests: use a size_t 2016-07-24 15:49:19 -04:00
Edward Thomson
e02f567641 repo::open: remove dead code, free buffers 2016-07-24 15:49:19 -04:00
wildart
bdec62dce1 remove conditions that prevent use of custom TLS stream 2016-07-06 13:06:25 -04:00
Edward Thomson
c18a2bc4e0 Merge pull request #3851 from txdv/get-user-agent
Add get user agent functionality.
2016-07-05 15:51:01 -04:00
Edward Thomson
b57c176aa9 Merge pull request #3846 from rkrp/fix_bug_parsing_int64min
Fixed bug while parsing INT64_MIN
2016-07-05 12:46:27 -04:00
Andrius Bentkus
f1dba14481 Add get user agent functionality. 2016-07-05 18:10:24 +03:00
Edward Thomson
ebeb56f0f5 Merge pull request #3711 from joshtriplett/git_repository_discover_default
Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars
2016-07-01 18:45:10 -04:00
Edward Thomson
6249d960ab index: include conflicts in git_index_read_index
Ensure that we include conflicts when calling `git_index_read_index`,
which will remove conflicts in the index that do not exist in the new
target, and will add conflicts from the new target.
2016-06-29 18:37:00 -04:00
Krishna Ram Prakash R
70b9b84179 Fixed bug while parsing INT64_MIN 2016-06-29 13:32:18 +05:30
Edward Thomson
20302aa437 Merge pull request #3223 from ethomson/apply
Reading patch files
2016-06-25 23:33:05 -04:00
Edward Thomson
1a79cd959b patch: show copy information for identical copies
When showing copy information because we are duplicating contents,
for example, when performing a `diff --find-copies-harder -M100 -B100`,
then show copy from/to lines in a patch, and do not show context.
Ensure that we can also parse such patches.
2016-06-25 23:08:30 -04:00
Edward Thomson
9eb1938134 patch::parse: test diff with exact rename and copy 2016-06-25 23:08:30 -04:00
Edward Thomson
8a670dc4c0 patch::parse: test diff with simple rename 2016-06-25 23:08:28 -04:00
Edward Thomson
e774d5af76 diff::parse tests: test parsing a diff
Test that we can create a diff file, then parse the results and
that the two are identical in-memory.
2016-06-25 23:08:04 -04:00
Josh Triplett
0dd98b6905 Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars
git_repository_open_ext provides parameters for the start path, whether
to search across filesystems, and what ceiling directories to stop at.
git commands have standard environment variables and defaults for each
of those, as well as various other parameters of the repository. To
avoid duplicate environment variable handling in users of libgit2, add a
GIT_REPOSITORY_OPEN_FROM_ENV flag, which makes git_repository_open_ext
automatically handle the appropriate environment variables. Commands
that intend to act just like those built into git itself can use this
flag to get the expected default behavior.

git_repository_open_ext with the GIT_REPOSITORY_OPEN_FROM_ENV flag
respects $GIT_DIR, $GIT_DISCOVERY_ACROSS_FILESYSTEM,
$GIT_CEILING_DIRECTORIES, $GIT_INDEX_FILE, $GIT_NAMESPACE,
$GIT_OBJECT_DIRECTORY, and $GIT_ALTERNATE_OBJECT_DIRECTORIES.  In the
future, when libgit2 gets worktree support, git_repository_open_env will
also respect $GIT_WORK_TREE and $GIT_COMMON_DIR; until then,
git_repository_open_ext with this flag will error out if either
$GIT_WORK_TREE or $GIT_COMMON_DIR is set.
2016-06-24 12:26:51 -07:00
Josh Triplett
39c6fca33a Add GIT_REPOSITORY_OPEN_NO_DOTGIT flag to avoid appending /.git
GIT_REPOSITORY_OPEN_NO_SEARCH does not search up through parent
directories, but still tries the specified path both directly and with
/.git appended.  GIT_REPOSITORY_OPEN_BARE avoids appending /.git, but
opens the repository in bare mode even if it has a working directory.
To support the semantics git uses when given $GIT_DIR in the
environment, provide a new GIT_REPOSITORY_OPEN_NO_DOTGIT flag to not try
appending /.git.
2016-06-24 11:44:01 -07:00
Josh Triplett
ed577134a5 Fix repository discovery with ceiling_dirs at current directory
git only checks ceiling directories when its search ascends to a parent
directory.  A ceiling directory matching the starting directory will not
prevent git from finding a repository in the starting directory or a
parent directory.  libgit2 handled the former case correctly, but
differed from git in the latter case: given a ceiling directory matching
the starting directory, but no repository at the starting directory,
libgit2 would stop the search at that point rather than finding a
repository in a parent directory.

Test case using git command-line tools:

/tmp$ git init x
Initialized empty Git repository in /tmp/x/.git/
/tmp$ cd x/
/tmp/x$ mkdir subdir
/tmp/x$ cd subdir/
/tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x git rev-parse --git-dir
fatal: Not a git repository (or any of the parent directories): .git
/tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x/subdir git rev-parse --git-dir
/tmp/x/.git

Fix the testsuite to test this case (in one case fixing a test that
depended on the current behavior), and then fix find_repo to handle this
case correctly.

In the process, simplify and document the logic in find_repo():
- Separate the concepts of "currently checking a .git directory" and
  "number of iterations left before going further counts as a search"
  into two separate variables, in_dot_git and min_iterations.
- Move the logic to handle in_dot_git and append /.git to the top of the
  loop.
- Only search ceiling_dirs and find ceiling_offset after running out of
  min_iterations; since ceiling_offset only tracks the longest matching
  ceiling directory, if ceiling_dirs contained both the current
  directory and a parent directory, this change makes find_repo stop the
  search at the parent directory.
2016-06-24 11:44:01 -07:00
Patrick Steinhardt
fe345c7306 Remove unused static functions 2016-06-21 07:58:33 +02:00
Patrick Steinhardt
8fd74c0806 Avoid old-style function definitions
Avoid declaring old-style functions without any parameters.
Functions not accepting any parameters should be declared with
`void fn(void)`. See ISO C89 $3.5.4.3.
2016-06-21 07:58:33 +02:00
Patrick Steinhardt
faebc1c6ec threads: split up OS-dependent thread code 2016-06-20 19:32:59 +02:00
Edward Thomson
bb0bd71ab4 checkout: use empty baseline when no index
When no index file exists and a baseline is not explicitly provided, use
an empty baseline instead of trying to load `HEAD`.
2016-06-15 15:47:28 -05:00
Patrick Steinhardt
292c60275e tests: fix memory leaks in checkout::typechange 2016-06-07 12:29:16 +02:00
Edward Thomson
5acf18ac63 rebase: test rebasing a new commit with subfolder
Test a rebase (both a merge rebase and an inmemory rebase) with a new
commit that adds files underneath a new subfolder.
2016-06-02 02:38:18 -05:00
Edward Thomson
91fbf9d867 test: ensure we can round-trip a written tree
Read a tree into an index, write the index, then re-open the index and
ensure that we are treesame to the original.
2016-06-02 02:37:04 -05:00
Edward Thomson
5baa20b86e round-trip trees through index_read_index
Read a tree into an index using `git_index_read_index` (by reading
a tree into a new index, then reading that index into the current
index), then write the index back out, ensuring that our new index
is treesame to the tree that we read.
2016-06-02 00:59:46 -05:00
Edward Thomson
c2f18b9b06 cleanup: unused warning 2016-06-01 10:03:51 -05:00
Edward Thomson
7166bb1665 introduce git_diff_from_buffer to parse diffs
Parse diff files into a `git_diff` structure.
2016-05-26 13:01:09 -05:00
Edward Thomson
94e488a056 patch: differentiate not found and invalid patches 2016-05-26 13:01:08 -05:00
Edward Thomson
17572f67ed git_patch_parse_ctx: refcount the context 2016-05-26 13:01:08 -05:00
Edward Thomson
9be638ecf0 git_diff_generated: abstract generated diffs 2016-05-26 13:01:08 -05:00
Edward Thomson
53571f2f0c vector: more sensible names for grow_at/shrink_at 2016-05-26 13:01:08 -05:00
Edward Thomson
440e3bae10 patch: git_patch_from_patchfile -> git_patch_from_buffer 2016-05-26 13:01:08 -05:00
Edward Thomson
e564fc65b5 git_vector_grow/shrink: correct shrink, and tests 2016-05-26 13:01:07 -05:00
Edward Thomson
0ff723cc90 apply: test postimages that grow/shrink original
Test with some postimages that actually grow/shrink from the
original, adding new lines or removing them.  (Also do so without
context to ensure that we can add/remove from a non-zero part of
the line vector.)
2016-05-26 13:01:07 -05:00
Edward Thomson
8cb27223b8 git_buf_quote/unquote: handle > \177
Parse values up to and including `\377` (`0xff`) when unquoting.
Print octal values as an unsigned char when quoting, lest `printf`
think we're talking about negatives.
2016-05-26 13:01:07 -05:00
Edward Thomson
6278fbc5dd patch parsing: squash some memory leaks 2016-05-26 13:01:07 -05:00
Edward Thomson
d3d95d5ae2 git_buf_quote: quote ugly characters 2016-05-26 13:01:06 -05:00
Edward Thomson
82175084e1 Introduce git_patch_options, handle prefixes
Handle prefixes (in terms of number of path components) for patch
parsing.
2016-05-26 13:01:06 -05:00
Edward Thomson
2f3b922ff1 patch_parse: test roundtrip patch parsing -> print 2016-05-26 13:01:05 -05:00
Edward Thomson
42b3442823 patch_parse: ensure we can parse a patch 2016-05-26 13:01:05 -05:00
Edward Thomson
8bca8b9e03 apply: move patch data to patch_common.h 2016-05-26 13:01:04 -05:00
Edward Thomson
804d5fe9f5 patch: abstract patches into diff'ed and parsed
Patches can now come from a variety of sources - either internally
generated (from diffing two commits) or as the results of parsing
some external data.
2016-05-26 13:01:04 -05:00
Edward Thomson
8d2eef27ff patch parsing: ensure empty patches are illegal 2016-05-26 13:01:04 -05:00
Edward Thomson
5d17d72621 patch parsing: parse binary patch files 2016-05-26 13:01:04 -05:00
Edward Thomson
b8dc2fdb92 zstream: fail when asked to inflate garbage
When we are provided some input buffer (with a length) to inflate,
and it contains more data than simply the deflated data, fail.
zlib will helpfully tell us when it is done reading (via Z_STREAM_END),
so if there is data leftover in the input buffer, fail lest we
continually try to inflate it.
2016-05-26 13:01:04 -05:00
Edward Thomson
5b78dbdbf3 git_buf: decode base85 inputs 2016-05-26 13:01:04 -05:00
Edward Thomson
3149ff6f66 patch application: apply binary patches
Handle the application of binary patches.  Include tests that
produce a binary patch (an in-memory `git_patch` object),
then enusre that the patch applies correctly.
2016-05-26 13:01:03 -05:00
Edward Thomson
b88f1713d0 zstream: offer inflating, git_zstream_inflatebuf
Introduce `git_zstream_inflatebuf` for simple uses.
2016-05-26 13:01:03 -05:00
Edward Thomson
0004386f29 apply: handle empty patches
When a patch is empty, simply copy the source into the destination.
2016-05-26 11:36:11 -05:00
Edward Thomson
d34f68261e Patch parsing from patch files 2016-05-26 11:36:11 -05:00
Edward Thomson
7cb904ba44 Introduce git_apply_patch
The beginnings of patch application from an existing (diff-created)
git_patch object: applies the hunks of a git_patch to a buffer.
2016-05-26 11:36:11 -05:00
Edward Thomson
e102daa4f6 Merge pull request #3798 from mmuman/stat-test-fix
test: Fix stat() test to mask out unwanted bits
2016-05-26 10:25:40 -05:00
Jason Haslam
afab1fff01 checkout: handle dirty submodules correctly
Don't generate conflicts when checking out a modified submodule and the
submodule is dirty or modified in the workdir.
2016-05-26 01:11:34 -05:00
François Revol
407f2e9fbd test: Fix stat() test to mask out unwanted bits
Haiku and Hurd both pass extra bits in struct stat::st_mode.
2016-05-24 20:01:49 +02:00
Carlos Martín Nieto
a2cb47130e tree: handle removal of all entries in the updater
When we remove all entries in a tree, we should remove that tree from
its parent rather than include the empty tree.
2016-05-24 14:30:43 +02:00
Carlos Martín Nieto
5341230536 tree: plug leaks in the tree updater 2016-05-19 15:29:53 +02:00
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
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
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
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
John Haley
4f22ccb979 Add tests for creating an initial commit 2016-05-03 13:32:32 -07:00
Edward Thomson
c7b4bbffcc rebase: test rebase (merge) w/ no common ancestor 2016-05-03 15:29:44 -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
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
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
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
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
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
1dc449105b Merge pull request #3110 from libgit2/cmn/proxy-config
Proxy configuration
2016-04-19 19:48:52 -04:00
Carlos Martín Nieto
1c3018eb12 ignore: fix directory limits when searching for star-star
In order to match the star-star, we disable the flag that's looking for
a single path element, but that leads to searching for the pattern in
the middle of elements in the input string.

Mark when we're handing a star-star so we jump over the elements in our
attempt to match the part of the pattern that comes after the star-star.

While here, tighten up the check so we don't allow invalid rules
through.
2016-04-19 19:39:05 +02:00
Carlos Martín Nieto
0d72f67f28 proxy: don't specify the protocol in the type
We leave this up to the scheme in the url field. The type should only
tell us about whether we want a proxy and whether we want to auto-detect
it.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
4e01741390 netops: make the path optional in URLs
When we're dealing with proxy addresses, we only want a hostname and
port, and the user would not provide a path, so make it optional so we
can use this same function to parse git as well as proxy URLs.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
b117721dd8 proxy: use poxy to test our Windows proxy support 2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
07bd3e57d9 proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
Antonio Scandurra
0f36271646 Add more tests for path matching with globs and path delimiters 2016-04-18 15:21:43 +02:00
Edward Thomson
bbd65ad27e tests: skip the unreadable file tests as root
When running as root, skip the unreadable file tests, because, well,
they're probably _not_ unreadable to root unless you've got some
crazy NSA clearance-level honoring operating system shit going on.
2016-04-11 15:32:38 -04:00
Edward Thomson
0e00eecf83 Merge pull request #3736 from libgit2/cmn/dwim-general-message
refs: provide a more general error message for dwim
2016-04-11 13:29:54 -04:00
Edward Thomson
d22a8b9583 refs::create: strict object creation on by default
When we turned strict object creation validation on by default, we
forgot to inform the refs::create tests of this.  They, in fact,
believed that strict object creation was off by default.  As a result,
their cleanup function went and turned strict object creation off for
the remaining tests.
2016-04-11 11:50:11 -04:00
Carlos Martín Nieto
6d22ef7a51 reset: use real ids for the tests
This lets us run with strict object creation on.
2016-04-11 11:47:56 -04:00
Carlos Martín Nieto
77965c685d refs: provide a more general error message for dwim
If we cannot dwim the input, set the error message to be explicit about
that. Otherwise we leave the error for the last failed lookup, which
can be rather unexpected as it mentions a remote when the user thought
they were trying to look up a branch.
2016-04-11 17:47:03 +02:00
Andreas Henriksson
04f47a43f9 tests: fix core/stream test when built with openssl off
When passing -DUSE_OPENSSL:BOOL=OFF to cmake the testsuite will
fail with the following error:

core::stream::register_tls [/tmp/libgit2/tests/core/stream.c:40]
  Function call failed: (error)
  error -1 - <no message>

Fix test to assume failure for tls when built without openssl.
While at it also fix GIT_WIN32 cpp to check if it's defined
or not.
2016-04-06 15:00:32 +02:00
Carlos Martín Nieto
381caf5690 Merge pull request #3724 from ethomson/submodule_start_supports_silly_slashes
iterator/diff: allow trailing `/` on start/end paths to match submodules
2016-04-02 22:19:42 -07:00
Edward Thomson
d47f7e1c15 iterator: support trailing / in start for submod
Allow callers to specify a start path with a trailing slash to match
a submodule, instead of just a directory.  This is for some legacy
behavior that's sort of dumb, but there it is.
2016-04-02 13:34:55 -07:00
Edward Thomson
2e0391f4f1 diff: test submodules are found with trailing /
Test that submodules are found when the are included in a pathspec
but have a trailing slash.
2016-04-02 13:02:41 -07:00
Carlos Martín Nieto
d364dc8b39 ignore: don't use realpath to canonicalize path
If we're looking for a symlink, realpath will give us the resolved path,
which is not what we're after, but a canonicalized version of the path
the user asked for.
2016-04-02 21:32:28 +02:00
Carlos Martín Nieto
1cac688d3f Merge pull request #3719 from libgit2/ethomson/submodule_status
WD iterator: properly identify submodules
2016-04-01 00:29:51 -07:00
Edward Thomson
74ab5f2cd0 status: test submodules with mixed case 2016-03-31 17:58:43 -04:00
Edward Thomson
17442b28f9 leaks: fix some leaks in the tests 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
f5c874a475 Plug a few leaks 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
2f0450f4d6 Merge pull request #3712 from ethomson/config_duplicate_section
config: don't write duplicate section
2016-03-29 03:26:43 -07:00
Edward Thomson
b085ecbe09 Merge pull request #3703 from libgit2/cmn/multivar-set-locked
config: don't special-case multivars that don't exist yet
2016-03-28 13:51:21 -04:00
Edward Thomson
76e1a679ea config::write::repeated: init our buffer 2016-03-28 08:56:13 -07:00
Carlos Martín Nieto
3e95bd36d9 config: show we write a spurious duplicated section header
We should notice that we are in the correct section to add. This is a
cosmetic bug, since replacing any of these settings does work.
2016-03-28 10:47:14 -04:00
Marc Strapetz
c017c18361 iterator: new workdir-iterator test for pathlist + includings trees 2016-03-24 15:59:49 -04:00
Marc Strapetz
09064f15c5 iterator: new index-iterator test for pathlist + includings trees 2016-03-24 15:59:49 -04:00
Marc Strapetz
8152a74821 iterator: more pathlist-related tests should test actual paths 2016-03-24 15:59:49 -04:00
Edward Thomson
d712c2b27f iterator: don't run the gunk test by default on CI
(It's slow!)
2016-03-24 15:59:48 -04:00
Edward Thomson
0ef0b71ca5 iterator: refactor index iterator 2016-03-24 15:59:48 -04:00
Edward Thomson
ba6f86eb2e Introduce git_path_common_dirlen 2016-03-24 15:59:48 -04:00
Edward Thomson
de034cd239 iterator: give the tests a proper hierarchy
Iterator tests were split over repo::iterator and diff::iterator,
with duplication between the two.  Move them to iterator::index,
iterator::tree, and iterator::workdir.
2016-03-24 15:59:48 -04:00
Jeff Hostetler
df25daef9b Added clar test for #3568 2016-03-23 17:17:02 -04:00
Edward Thomson
6cd9573f54 iterator: test that we can advance_into empty dirs
Prior iterator implementations returned `GIT_ENOTFOUND` when
trying to advance into empty directories.  Ensure that we no longer
do that and simply handle them gracefully.
2016-03-23 17:17:02 -04:00
joshaber
b620426006 Failing test. 2016-03-23 17:17:02 -04:00
Marc Strapetz
ae86aa5a68 iterator: test pathlist handling for directories
tree_iterator was only working properly for a pathlist containing
file paths. In case of directory paths, it didn't match children
which contradicts GIT_DIFF_DISABLE_PATHSPEC_MATCH and
is different from index_iterator and fs_iterator.

As a consequence head-to-index status reporting for a specific
directory did not work properly -- all files have been reported
as added.

Include additional tests.
2016-03-23 17:16:38 -04:00
Edward Thomson
6bcddf88b3 iterator: test advance_over with a pathlist 2016-03-23 17:16:38 -04:00
Edward Thomson
9fb2527f3c iterator: add tests for advance_over
`git_iterator_advance_over` is a gnarly bit of code with no actual
tests.
2016-03-23 17:16:37 -04:00
Edward Thomson
85541f4390 iterator: test workdir pathlist with deep paths
In the workdir iterator we do some tricky things to step down into
directories to look for things that are in our pathlist.  Make sure
that we don't confuse between folders that we're definitely going to
return everything in and folders that we're only stepping down into
to keep looking for matches.
2016-03-23 17:16:37 -04:00
Edward Thomson
908d8de8c3 iterator: workdir tests with submodules
Ensure that when specifying start/end paths, or pathlists, that we
deal correctly with submodules.
2016-03-23 17:16:37 -04:00
Edward Thomson
c3d195f1d9 iterator: expand workdir tests with pathlist
Expand the workdir tests to validate the paths in case sensitive
and insensitive tests.
2016-03-23 17:16:37 -04:00
Edward Thomson
4c88198a85 iterator: test that we're at the end of iteration
Ensure that we have hit the end of iteration; previously we tested
that we saw all the values that we expected to see.  We did not
then ensure that we were at the end of the iteration (and that there
were subsequently values in the iteration that we did *not* expect.)
2016-03-23 17:16:37 -04:00
Edward Thomson
d051de243c iterator: test fs iterator w/ many nested empty dirs 2016-03-23 17:08:37 -04:00
Edward Thomson
a4f520a6f6 iterator: skip unreadable directories in fs iterator
Do not abort iteration in the middle when encountering an unreadable
directory.  Instead, skip it, as if it didn't exist.
2016-03-23 17:08:37 -04:00
Edward Thomson
be30387e8b iterators: refactored tree iterator
Refactored the tree iterator to never recurse; simply process the
next entry in order in `advance`.  Additionally, reduce the number of
allocations and sorting as much as possible to provide a ~30% speedup
on case-sensitive iteration.  (The gains for case-insensitive iteration
are less majestic.)
2016-03-23 17:08:37 -04:00
Edward Thomson
277c85eb1c repo::iterator: don't go out of bounds 2016-03-23 17:08:37 -04:00
Edward Thomson
684b35c41b iterator: disambiguate reset and reset_range
Disambiguate the reset and reset_range functions.  Now reset_range
with a NULL path will clear the start or end; reset will leave the
existing start and end unchanged.
2016-03-23 17:08:37 -04:00
Edward Thomson
8a5a2e2f0e status: update test to include valid OID 2016-03-23 17:08:36 -04:00
Carlos Martín Nieto
661db4f482 Merge pull request #3704 from ethomson/tree-reuse
tree: drop the now-unnecessary entries vector
2016-03-23 03:45:53 -07:00
Carlos Martín Nieto
6669e3e839 blob: remove _fromchunks()
The callback mechanism makes it awkward to write data from an IO
source; move to `_fromstream()` which lets the caller remain in control,
in the same vein as we prefer iterators over foreach callbacks.
2016-03-22 20:00:25 +01:00
Carlos Martín Nieto
35e68606da blob: fix fromchunks iteration counter
By returning when the count goes to zero rather than below it, setting
`howmany` to 7 in fact writes out the string 6 times.

Correct the termination condition to write out the string the amount of
times we specify.
2016-03-22 20:00:24 +01:00
Carlos Martín Nieto
0a5c602889 blob: introduce creating a blob by writing into a stream
The pair of `git_blob_create_frombuffer()` and
`git_blob_create_frombuffer_commit()` is meant to replace
`git_blob_create_fromchunks()` by providing a way for a user to write a
new blob when they want filtering or they do not know the size.

This approach allows the caller to retain control over when to add data
to this buffer and a more natural fit into higher-level language's own
stream abstractions instead of having to handle IO wait in the callback.

The in-memory buffer size of 2MB is chosen somewhat arbitrarily to be a
round multiple of usual page sizes and a value where most blobs seem
likely to be either going to be way below or way over that size. It's
also a round number of pages.

This implementation re-uses the helper we have from `_fromchunks()` so
we end up writing everything to disk, but hopefully more efficiently
than with a default filebuf. A later optimisation can be to avoid
writing the in-memory contents to disk, with some extra complexity.
2016-03-22 19:34:08 +01:00
Edward Thomson
e2e4bae9a0 tree: drop the now-unnecessary entries vector
Remove the now-unnecessary entries vector.  Add `git_array_search`
to binary search through an array to accomplish this.
2016-03-22 06:21:13 -07:00
Carlos Martín Nieto
6f09911c0f config: don't special-case multivars that don't exist yet
This special-casing ignores that we might have a locked file, so the
hashtable does not represent the contents of the file we want to
write. This causes multivar writes to overwrite entries instead of add
to them when under lock.

There is no need for this as the normal code-path will write to the file
just fine, so simply get rid of it.
2016-03-21 22:25:12 +01:00
Carlos Martín Nieto
60a194aa86 tree: re-use the id and filename in the odb object
Instead of copying over the data into the individual entries, point to
the originals, which are already in a format we can use.
2016-03-20 11:00:12 +01:00
Edward Thomson
d953c4505e merge drivers: handle configured but not found driver 2016-03-17 11:06:00 -04:00
Edward Thomson
6d8b2cdbee merge driver: remove check callback
Since the `apply` callback can defer, the `check` callback is not
necessary.  Removing the `check` callback further makes the `payload`
unnecessary along with the `cleanup` callback.
2016-03-17 11:06:00 -04:00
Edward Thomson
58d33126d4 merge driver: tests for set and unset merge attribute
Ensure that setting the merge attribute forces the built-in default
`text` driver and does *not* honor the `merge.default` configuration
option.  Further ensure that unsetting the merge attribute forces
a conflict (the `binary` driver).
2016-03-17 11:02:27 -04:00
Edward Thomson
d3f0875a60 merge driver: tests for custom default merge drivers 2016-03-17 11:02:27 -04:00
Edward Thomson
7d307c1edc merge driver: test GIT_EMERGECONFLICT
When a `check` or `apply` callback function returns `GIT_EMERGECONFLICT`
stop and product a conflict.
2016-03-17 11:02:27 -04:00
Edward Thomson
59f2931465 merge driver: test GIT_PASSTHROUGH
When a `check` or `apply` callback function returns `GIT_PASSTHROUGH`,
move on to the default merge driver.
2016-03-17 11:02:27 -04:00
Edward Thomson
3f04219fcd merge driver: introduce custom merge drivers
Consumers can now register custom merged drivers with
`git_merge_driver_register`.  This allows consumers to support the
merge drivers, as configured in `.gitattributes`.  Consumers will be
asked to perform the file-level merge when a custom driver is
configured.
2016-03-17 11:02:26 -04:00
Stan Hu
7a74590d8f Fix rebase bug and include test for merge=union 2016-03-17 11:02:26 -04:00
Edward Thomson
ba3493228c Merge pull request #3673 from libgit2/cmn/commit-with-signature
commit: add function to attach a signature to a commit
2016-03-17 06:57:56 -07:00
Edward Thomson
a151eb544b Merge pull request #3685 from pks-t/pks/memleaks
Test memleaks
2016-03-17 06:55:24 -07:00
Carlos Martín Nieto
bf804d407e commit: fix extraction of single-line signatures
The function to extract signatures suffers from a similar bug to the
header field finding one by having an unecessary line feed check as a
break condition of its loop.

Fix that and add a test for this single-line signature situation.
2016-03-17 10:48:06 +01:00
Carlos Martín Nieto
02d61a3b66 commit: add function to attach a signature to a commit
In combination with the function which creates a commit into a buffer,
this allows us to more easily create signed commits.
2016-03-15 12:55:03 +01:00
Dirkjan Bussink
c577efbbb5 Use general cl_git_fail because the error is generic 2016-03-14 12:41:41 +00:00
Dirkjan Bussink
fa72d6daf8 Setup better defaults for OpenSSL ciphers
This ensures that when using OpenSSL a safe default set of ciphers
is selected. This is done so that the client communicates securely
and we don't accidentally enable unsafe ciphers like RC4, or even
worse some old export ciphers.

Implements the first part of https://github.com/libgit2/libgit2/issues/3682
2016-03-14 12:07:13 +00:00
Patrick Steinhardt
35b7bca28b tests: transport: fix memory leaks with registering transports 2016-03-11 11:06:42 +01:00
Patrick Steinhardt
e756877dbf tests: nsec: correctly free nsec_path
git_buf_clear does not free allocated memory associated with a
git_buf. Use `git_buf_free` instead to correctly free its memory
and plug the memory leak.
2016-03-11 09:07:42 +01:00
Carlos Martín Nieto
2ba9a0ddac Merge pull request #3623 from ethomson/rebase_with_commit
rebase: additional setup tests of exotic behavior
2016-03-09 23:45:33 +01:00
Vicent Marti
9a78665005 odb: Handle corner cases in git_odb_expand_ids
The old implementation had two issues:

1. OIDs that were too short as to be ambiguous were not being handled
properly.

2. If the last OID to expand in the array was missing from the ODB, we
would leak a `GIT_ENOTFOUND` error code from the function.
2016-03-09 11:00:27 +01:00
Vicent Marti
c68044a879 Merge pull request #3656 from ethomson/exists_prefixes
Introduce `git_odb_expand_ids`
2016-03-08 21:17:38 +01:00
Edward Thomson
62484f52d1 git_odb_expand_ids: accept git_odb_expand_id array
Take (and write to) an array of a struct, `git_odb_expand_id`.
2016-03-08 14:57:20 -05:00
Edward Thomson
4b1f0f79ac git_odb_expand_ids: rename func, return the type 2016-03-08 11:44:21 -05:00
Edward Thomson
b7809b8469 Merge pull request #3555 from cbargren/ssh-git-protocols
Support for ssh+git and git+ssh protocols
2016-03-08 13:38:55 +00:00
Edward Thomson
534ca8882d Merge pull request #3652 from libgit2/cmn/commit-to-memory
commit: split creating the commit and writing it out
2016-03-08 13:35:11 +00:00
Carlos Martín Nieto
47cb42da5a commit: split creating the commit and writing it out
Sometimes you want to create a commit but not write it out to the
objectdb immediately. For these cases, provide a new function to
retrieve the buffer instead of having to go through the db.
2016-03-08 13:11:49 +01:00
Carlos Martín Nieto
eeff96c474 Merge pull request #3655 from ethomson/nanosecond_defaults
Enable nanosecond resolution by default
2016-03-08 10:43:33 +01:00
Edward Thomson
53fb823bcc index::racy: force racy entry
Instead of hoping that we can get a racy entry by going real fast
and praying real hard, just create a racy entry.
2016-03-08 00:47:55 -05:00
Edward Thomson
565c419972 index::nsec: don't expect shit filesystems to not suck
If the underlying filesystem doesn't support better than one
second resolution, then don't expect that turning on `GIT_USE_NSEC`
does anything magical to change that.
2016-03-07 17:04:32 -05:00
Edward Thomson
6c04269c8f git_odb_exists_many_prefixes: query odb for multiple short ids
Query the object database for multiple objects at a time, given their
object ID (which may be abbreviated) and optional type.
2016-03-07 16:10:25 -05:00
Edward Thomson
6abdf52d6e merge::workdir::dirty: update to use st_ctime_nsec
Update unit test to use newfangled `st_ctime_nsec`, which provides
indirection to the platform-correct name.
2016-03-07 09:37:51 -05:00
Carlos Martín Nieto
ea5bf6bbce treebuilder: don't try to verify submodules exist in the odb
Submodules don't exist in the objectdb and the code is making us try to
look for a blob with its commit id, which is obviously not going to
work.

Skip the test if the user wants to insert a submodule.
2016-03-04 12:38:28 +01:00
Carlos Martín Nieto
e23efa6ddf tests: take the version from our define 2016-03-03 21:03:10 +01:00
Carlos Martín Nieto
9b3fc895b7 tests: plug a leak 2016-03-03 11:17:36 +01:00
Edward Thomson
09d9968014 rebase: additional tests for completing a rebase 2016-02-28 20:10:44 -05:00
Edward Thomson
f2dddf52c0 turn on strict object validation by default 2016-02-28 18:59:43 -05:00
Edward Thomson
4afe536ba1 tests: use legitimate object ids
Use legitimate (existing) object IDs in tests so that we have the
ability to turn on strict object validation when running tests.
2016-02-28 18:54:56 -05:00
Edward Thomson
98c341496f refs: honor strict object creation 2016-02-28 18:54:39 -05:00
Edward Thomson
6ddf533afc git_index_add: validate objects in index entries (optionally)
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the index entries given to `git_index_add`.
2016-02-28 18:54:39 -05:00
Edward Thomson
2bbc7d3e56 treebuilder: validate tree entries (optionally)
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to treebuilder insertion.
2016-02-28 12:38:40 -05:00
Edward Thomson
ef63bab306 git_commit: validate tree and parent ids
When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to commit creation functions.
2016-02-28 12:38:39 -05:00
Edward Thomson
6cc4bac894 Merge pull request #3577 from rossdylan/rossdylan/pooldebug
Add a new build flag to disable the pool allocator
2016-02-28 11:31:10 -05:00
Edward Thomson
a4c55069e3 nsec: update staging test for GIT_USE_NSECS
The index::nsec::staging_maintains_other_nanos test was created to
ensure that when we stage an entry when GIT_USE_NSECS is *unset* that
we truncate the index entry and do not persist the (old, invalid)
nanosec values.  Ensure that when GIT_USE_NSECS is *set* that we do
not do that, and actually write the correct nanosecond values.
2016-02-25 11:40:40 -05:00
Edward Thomson
7bab2e8fbf git_libgit2_opts: validate key 2016-02-22 23:07:30 -05:00
Carlos Martín Nieto
5663d4f691 Merge pull request #3613 from ethomson/fixups
Remove most of the silly warnings
2016-02-18 12:31:56 +01:00
Carlos Martín Nieto
594a5d12d4 Merge pull request #3619 from ethomson/win32_forbidden
win32: allow us to read indexes with forbidden paths on win32
2016-02-18 12:28:06 +01:00
Edward Thomson
2a39818c37 rebase: additional setup tests of exotic behavior
Test some additional exotic rebase setup behavior:  that we are
able to set up properly when already in a detached HEAD state,
that the caller specifies all of branch, upstream and onto,
and that the caller specifies branch, upstream and onto by ID.
2016-02-17 16:22:15 +00:00
Edward Thomson
318b825e76 index: allow read of index w/ illegal entries
Allow `git_index_read` to handle reading existing indexes with
illegal entries.  Allow the low-level `git_index_add` to add
properly formed `git_index_entry`s even if they contain paths
that would be illegal for the current filesystem (eg, `AUX`).
Continue to disallow `git_index_add_bypath` from adding entries
that are illegal universally illegal (eg, `.git`, `foo/../bar`).
2016-02-17 13:10:33 +00:00
Edward Thomson
4be2aa57c9 win32: tests around handling forbidden paths
Introduce a repository that contains some paths that were illegal
on PC-DOS circa 1981 (like `aux`, `con`, `com1`) and that in a
bizarre fit of retrocomputing, remain illegal on some "modern"
computers, despite being "new technology".

Introduce some aspirational tests that suggest that we should be
able to cope with trees and indexes that contain paths that
would be illegal on the filesystem, so that we can at least diff
them.  Further ensure that checkout will not write a repository
with forbidden paths.
2016-02-17 13:10:33 +00:00
Carlos Martín Nieto
eadd0f05f6 commit: expose the different kinds of errors
We should be checking whether the object we're looking up is a commit,
and we should let the caller know whether the not-found return code
comes from a bad object type or just a missing signature.
2016-02-16 14:06:48 +01:00
Edward Thomson
0d9a39eaf5 win32: drop incorrect constness 2016-02-16 11:50:45 +00:00
Edward Thomson
f28bae0c38 rebase: persist a single in-memory index
When performing an in-memory rebase, keep a single index for the
duration, so that callers have the expected index lifecycle and
do not hold on to an index that is free'd out from under them.
2016-02-15 19:27:06 +00:00
Edward Thomson
35439f5997 win32: introduce p_timeval that isn't stupid
Windows defines `timeval` with `long`, which we cannot
sanely cope with.  Instead, use a custom timeval struct.
2016-02-12 10:34:15 -08:00
Carlos Martín Nieto
5a296ad07e Merge pull request #3610 from ethomson/rebase_bare
rebase: introduce bare rebasing
2016-02-12 00:55:20 +01:00
Arthur Schreiber
3679ebaef5 Horrible fix for #3173. 2016-02-11 23:41:34 +01:00
Carlos Martín Nieto
460ae11f0a commit: don't forget the last header field
When we moved the logic to handle the first one, wrong loop logic was
kept in place which meant we still finished early. But we now notice it
because we're not reading past the last LF we find.

This was not noticed before as the last field in the tested commit was
multi-line which does not trigger the early break.
2016-02-11 22:19:20 +01:00
Edward Thomson
263e674ec6 merge tests: correct casts 2016-02-11 11:41:23 -08:00
Edward Thomson
ad8aa11288 reset test: fix initialization warning 2016-02-11 11:26:42 -08:00
Edward Thomson
a202e0d45b rebase: allow custom merge_options
Allow callers of rebase to specify custom merge options.  This may
allow custom conflict resolution, or failing fast when conflicts
are detected.
2016-02-11 10:49:25 -08:00
Edward Thomson
ee6673070a rebase: introduce inmemory rebasing
Introduce the ability to rebase in-memory or in a bare repository.

When `rebase_options.inmemory` is specified, the resultant `git_rebase`
session will not be persisted to disk.  Callers may still analyze
the rebase operations, resolve any conflicts against the in-memory
index and create the commits.  Neither `HEAD` nor the working
directory will be updated during this process.
2016-02-11 10:48:48 -08:00
Vicent Marti
488e2b8505 Merge pull request #3599 from libgit2/gpgsign
Introduce git_commit_extract_signature
2016-02-09 16:26:58 +01:00
Carlos Martín Nieto
a65afb757e Introduce git_commit_extract_signature
This returns the GPG signature for a commit and its contents without the
signature block, allowing for the verification of the commit's
signature.
2016-02-09 15:58:16 +01:00
Carlos Martín Nieto
f55eca167c commit: also match the first header field when searching
We were searching only past the first header field, which meant we were
unable to find e.g. `tree` which is the first field.

While here, make sure to set an error message in case we cannot find the
field.
2016-02-09 07:17:26 +01:00
Ross Delinger
ed0571f895 Add a new build flag to disable the pool allocator and pass all git_pool_malloc calls straight to git__malloc 2016-01-12 16:08:38 -05:00
Chris Bargren
1cc7f544a0 Adding test cases that actually test the functionality of the new transport
ssh, ssh+git and git+ssh should all successfully build an SSH transport
2015-12-28 11:45:07 -07:00
Edward Thomson
62602547db git_repository_init: include dotfiles when copying templates
Include dotfiles when copying template directory, which will handle
both a template directory itself that begins with a dotfile, and
any dotfiles inside the directory.
2015-12-26 22:41:00 -06:00
Edward Thomson
002821837f repo::init tests: test a template dir with leading dot
Ensure that we can handle template directories that begin with a
leading dot.
2015-12-26 22:32:17 -06:00
Edward Thomson
5c042c5bf5 repo::init tests: test init.templatedir setting
Ensure that `git_repository_init` honors the `init.templatedir`
configuration setting.
2015-12-26 22:06:45 -06:00
Chris Bargren
0c1f56722b Adding spec coverage for ssh+git and git+ssh protocols 2015-12-22 10:56:38 -07:00
Dmitriy Olshevskiy
91f0d186b4 typos in comments 2015-12-21 22:18:07 +03:00
Vicent Marti
5951445fb3 commit: Fix memory leak in test suite 2015-12-17 10:13:04 +01:00
Edward Thomson
30c8e26074 Merge pull request #3521 from pks-t/blame-line-overflow
Line count overflow in git_blame_hunk and git_blame__entry
2015-12-14 13:53:26 -06:00
Carlos Martín Nieto
6aa06b65cf Merge pull request #3522 from pks-t/email-format-commit-message
diff: include commit message when formatting patch
2015-12-10 12:14:09 +01:00
Carlos Martín Nieto
465c3b38d5 reset: perform the checkout before moving HEAD or the index
This keeps the state of the workdir the same as one from HEAD, removing
a source of possible confusion when calculating the work that is to be
done.
2015-12-09 19:16:11 +01:00
Michał Górny
326c9fc2ed checkout test: Apply umask to file-mode test as well
Fix the file-mode test to expect system umask being applied to the
created file as well (it is currently applied to the directory only).
This fixes the test on systems where umask != 022.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2015-12-01 20:42:56 +01:00
Patrick Steinhardt
254e0a33ee diff: include commit message when formatting patch
When formatting a patch as email we do not include the commit's
message in the formatted patch output. Implement this and add a
test that verifies behavior.
2015-12-01 10:12:53 +01:00
Patrick Steinhardt
7f8fe1d45e commit: introduce git_commit_body
It is already possible to get a commit's summary with the
`git_commit_summary` function. It is not possible to get the
remaining part of the commit message, that is the commit
message's body.

Fix this by introducing a new function `git_commit_body`.
2015-12-01 10:07:00 +01:00
Patrick Steinhardt
cb1cb24ca9 blame: use size_t for line counts in git_blame_hunk
It is not unreasonable to have versioned files with a line count
exceeding 2^16. Upon blaming such files we fail to correctly keep
track of the lines as `git_blame_hunk` stores them in `uint16_t`
fields.

Fix this by converting the line fields of `git_blame_hunk` to
`size_t`. Add test to verify behavior.
2015-12-01 09:02:47 +01:00
Patrick Steinhardt
a7bd157ebf tests: fix warning for nested struct initialization 2015-11-30 17:40:49 +01:00
Carlos Martín Nieto
a27f31d8f5 Merge pull request #3513 from ethomson/merge_recursive
Recursive Merge
2015-11-30 04:49:31 +01:00
Edward Thomson
5b9c63c3f6 recursive merge: add a recursion limit 2015-11-25 16:25:47 -05:00
Edward Thomson
78859c6344 merge: handle conflicts in recursive base building
When building a recursive merge base, allow conflicts to occur.
Use the file (with conflict markers) as the common ancestor.

The user has already seen and dealt with this conflict by virtue
of having a criss-cross merge.  If they resolved this conflict
identically in both branches, then there will be no conflict in the
result.  This is the best case scenario.

If they did not resolve the conflict identically in the two branches,
then we will generate a new conflict.  If the user is simply using
standard conflict output then the results will be fairly sensible.
But if the user is using a mergetool or using diff3 output, then the
common ancestor will be a conflict file (itself with diff3 output,
haha!).  This is quite terrible, but it matches git's behavior.
2015-11-25 15:38:39 -05:00
Edward Thomson
34a51428a1 merge tests: add complex recursive example 2015-11-25 15:38:33 -05:00
Edward Thomson
651bfd699c recursive: test conflict output during recursive merge 2015-11-25 15:38:28 -05:00
Edward Thomson
dcde572042 merge tests: move expected data into own file 2015-11-25 15:38:22 -05:00
Edward Thomson
b1eef912cf merge: add recursive test with conflicting contents 2015-11-25 15:37:51 -05:00
Edward Thomson
fccad82ee8 merge: add recursive test with three merge bases 2015-11-25 15:37:39 -05:00
Edward Thomson
99d9d9a470 merge: improve test names in recursive merge tests 2015-11-25 15:37:33 -05:00
Edward Thomson
a200bcf728 merge: add a third-level recursive merge 2015-11-25 15:37:28 -05:00
Edward Thomson
cdb6c1c83d merge: add a second-level recursive merge 2015-11-25 15:37:22 -05:00
Edward Thomson
86c8d02c07 merge: add simple recursive test
Add a simple recursive test - where multiple ancestors exist and
creating a virtual merge base from them would prevent a conflict.
2015-11-25 15:37:11 -05:00
Edward Thomson
fa78782f67 merge: rename git_merge_tree_flags_t -> git_merge_flags_t 2015-11-25 15:37:05 -05:00
Patrick Steinhardt
77b79dde84 tests: win32::longpath: free expected_msg 2015-11-24 15:21:52 +01:00
Patrick Steinhardt
9031be180b tests: config::stress: free git_config structs 2015-11-24 15:21:52 +01:00
Patrick Steinhardt
c8fab201eb tests: config::global: fix memleak in open_programdata 2015-11-24 14:47:50 +01:00
Edward Thomson
c4f60543b7 Merge pull request #3517 from jacquesg/warnings-fixes
Fix some warnings
2015-11-20 17:57:04 -05:00
Jacques Germishuys
87428c556f Fix some warnings 2015-11-20 20:48:51 +02:00
Carlos Martín Nieto
2ea40fdaac repository: distinguish sequencer cherry-pick and revert
These are not quite like their plain counterparts and require special handling.
2015-11-20 13:19:23 -05:00
Carlos Martín Nieto
69d1494873 Merge pull request #3511 from ethomson/racy_fixes_2
Racy fixes for writing new indexes
2015-11-17 13:21:18 -05:00
Edward Thomson
88638f9b18 tests: use out-of-the-way config dir in sandbox
Don't put the configuration in a subdir of the sandbox named
`config`, lest some tests decide to create their own directory
called `config`.  Prefix with some underscores for uniqueness.
2015-11-17 11:22:01 -05:00
Edward Thomson
fe96374823 tests: set PROGRAMDATA directory for running tests 2015-11-17 08:47:26 -05:00
Edward Thomson
6f7c411834 config::global: use PROGRAMDATA configuration
Query the `GIT_CONFIG_LEVEL_PROGRAMDATA` location when setting it up
for tests, in case the test runner has sandboxed it.
2015-11-17 08:46:21 -05:00
Edward Thomson
5f32c50683 racy: make git_index_read_index handle raciness
Ensure that `git_index_read_index` clears the uptodate bit on
files that it modifies.

Further, do not propagate the cache from an on-disk index into
another on-disk index.  Although this should not be done, as
`git_index_read_index` is used to bring an in-memory index into
another index (that may or may not be on-disk), ensure that we do
not accidentally bring in these bits when misused.
2015-11-16 22:59:02 -05:00
Edward Thomson
c30051f0d0 racy: ensure git_index_read_tree clears uptodate
Ensure that `git_index_read_tree` clears the uptodate bit on files
that it modifies.
2015-11-16 22:59:01 -05:00
Edward Thomson
956f4da897 index: test for smudged entries on write only
Test that entries are only smudged when we write the index: the
entry smudging is to prevent us from updating an index in a way
that it would be impossible to tell that an item was racy.
Consider when we load an index:  any entries that have the same
(or newer) timestamp than the index itself are considered racy,
and are subject to further scrutiny.

If we *save* that index with the same entries that we loaded,
then the index would now have a newer timestamp than the entries,
and they would no longer be given that additional scrutiny, failing
our racy detection!  So test that we smudge those entries only on
writing the new index, but that we can detect them (in diff) without
having to write.
2015-11-16 22:58:59 -05:00
Edward Thomson
de999f260f checkout::crlf test: don't crash when no idx entry
When there's no matching index entry (for whatever reason), don't
try to dereference the null return value to get at the id.

Otherwise when we break something in the index API, the checkout
test crashes for confusing reasons and causes us to step through
it in a debugger thinking that we had broken much more than we
actually did.
2015-11-16 22:58:59 -05:00
Edward Thomson
d1101263f7 index: don't detect raciness in uptodate entries
Keep track of entries that we believe are up-to-date, because we
added the index entries since the index was loaded.  This prevents
us from unnecessarily examining files that we wrote during the
cleanup of racy entries (when we smudge racily clean files that have
a timestamp newer than or equal to the index's timestamp when we
read it).  Without keeping track of this, we would examine every
file that we just checked out for raciness, since all their timestamps
would be newer than the index's timestamp.
2015-11-16 22:58:58 -05:00
Vicent Marti
7ff7ca623e pool: Never return unaligned buffers 2015-11-13 04:57:19 +01:00
Carlos Martín Nieto
75a0ccf52f Merge pull request #3170 from CmdrMoozy/nsec_fix
git_index_entry__init_from_stat: set nsec fields in entry stats
2015-11-12 19:53:09 +01:00
Carlos Martín Nieto
2c26c8679f Merge pull request #3499 from ethomson/ref_dir_errmsgs
Improve error messages when dirs prevent ref/reflog creation
2015-11-12 19:22:31 +01:00
Carlos Martín Nieto
ecdc04287a Merge pull request #3448 from libgit2/cmn/custom-agent
Support setting custom user-agent
2015-11-12 19:20:36 +01:00
Carlos Martín Nieto
de870533e0 settings: add a setter for a custom user-agent 2015-11-12 17:18:42 +01:00
Edward Thomson
0a700ee368 reflog: error when a directory is at reflog path
When a non-empty directory exists and prevents the creation of a
reflog, provide a more informative error message.
2015-11-12 09:39:29 -05:00
Edward Thomson
b46c7ee5e2 refs: complain when a directory exists at ref
When a (non-empty) directory exists at the reference target
location, complain with a more actionable error message.
2015-11-12 09:35:51 -05:00
nulltoken
1314af8d63 Failing test for case sensitive conflicts in the index 2015-11-12 12:11:45 +01:00
Carlos Martín Nieto
1c34b717e0 Merge pull request #3498 from ethomson/windows_symlinks
Diff: Honor `core.symlinks=false` and fake symlinks
2015-11-08 05:10:18 +01:00
Carlos Martín Nieto
619488948b Merge pull request #3500 from ethomson/submodules_with_path
Handle submodules with paths in `git_submodule_update`
2015-11-08 04:54:55 +01:00
Edward Thomson
790012ce78 submodule: test updating a submodule w/ a path
Test that `git_submodule_update` can handle a submodule that is
freshly cloned and has a path differing from its name.
2015-11-04 16:53:41 -05:00
Edward Thomson
5aa28a8f2d Merge pull request #3465 from libgit2/cmn/tls-register
stream: allow registering a user-provided TLS constructor
2015-11-04 14:16:24 -05:00
Stjepan Rajko
f5f96a23ee Fix git_commit_summary to convert newlines to spaces even after
whitespace.  Collapse spaces around newlines for the summary.
2015-11-03 17:50:55 -05:00
Edward Thomson
ec50b23acc filebuf: detect directories in our way
When creating a filebuf, detect a directory that exists in our
target file location.  This prevents a failure later, when we try
to move the lock file to the destination.
2015-11-03 17:16:51 -05:00
Edward Thomson
2d556f3166 reflog: test reflog is deleted when ref is deleted 2015-11-03 14:48:31 -05:00
Edward Thomson
6cc5023bfd index: test that add_bypath preserves symlinks
Test that on platforms without `core.symlinks`, we preserve symlinks
in `git_index_add_bypath`.  (Users should correct the actual index
entry's mode to change a link to a regular file.)
2015-11-03 12:07:03 -05:00