Commit Graph

1598 Commits

Author SHA1 Message Date
Edward Thomson
ef4857c2b3 errors: tighten up git_error_state OOMs a bit more
When an error state is an OOM, make sure that we treat is specially
and do not try to free it.
2015-08-03 19:44:51 -04:00
Edward Thomson
bdec336301 win32: ensure hidden files can be staged 2015-08-03 18:33:15 -05:00
Michael Procter
988ea59443 Test: check restored oom error points to static buffer 2015-08-03 15:23:17 +01:00
Michael Procter
5ef4b86015 Add failing test for capture/restore oom error 2015-08-03 15:23:17 +01:00
Edward Thomson
69adb781e1 Merge pull request #3325 from libgit2/cmn/filebuf-rename-error
filebuf: remove lockfile upon rename errors
2015-08-03 08:33:53 -05:00
Carlos Martín Nieto
b426ac90a9 index: test that an unregistered submodule gets staged
When we pass the path of a repository to `_bypath()`, we should behave
like git and stage it as a `_COMMIT` regardless of whether it is
registered a a submodule.
2015-08-01 19:52:25 +02:00
Linquize
63e5b55122 index: add test for adding an old-style submodule to index 2015-08-01 19:35:59 +02:00
Edward Thomson
9d4b7d2524 Merge pull request #3328 from libgit2/cmn/iterator-skip-diriter
iterator: skip over errors in diriter init
2015-07-29 16:46:47 -05:00
Carlos Martín Nieto
0e391d8526 iterator: adjust unreadable-dir test to new behaviour
We don't want the iterator to make us stop whenever we hit an unreadable
dir. We should instead move over to the next item.
2015-07-27 13:31:06 +02:00
Carlos Martín Nieto
19d9beb7ff filebuf: remove lockfile upon rename errors
When we have an error renaming the lockfile, we need to make sure
that we remove it upon cleanup. For this, we need to keep track of
whether we opened the file and whether the rename succeeded.

If we did create the lockfile but the rename did not succeed, we
remove the lockfile. This won't protect against all errors, but
the most common ones (target file is open) does get handled.
2015-07-24 23:02:11 +02:00
Carlos Martín Nieto
668053befe filebuf: failing test for leaving the lockfile when failing to rename
When we fail to rename, we currently leave the lockfile laying
around. This shows that behaviour.
2015-07-24 22:55:43 +02:00
Edward Thomson
2dfd5eae33 Merge pull request #3307 from libgit2/cmn/submodule-backslash
Normalize submodule urls before looking at them
2015-07-24 15:05:16 -05:00
Edward Thomson
759b2230a5 Merge pull request #3303 from libgit2/cmn/index-add-submodule
Allow adding a submodule through git_index_add_bypath
2015-07-24 15:04:20 -05:00
Edward Thomson
91dad18143 Merge pull request #3305 from libgit2/cmn/reflog-del-backend
refdb: delete a ref's reflog upon deletion
2015-07-24 15:01:04 -05:00
Carlos Martín Nieto
ceb5873913 Merge pull request #3302 from libgit2/cmn/submodule-foreach-diff-path
List a submodule only once when the path matches a submodule in the index
2015-07-13 18:50:39 +02:00
Carlos Martín Nieto
aa51fa1e03 submodule: add failing test for backslash in url 2015-07-13 08:39:35 +02:00
Carlos Martín Nieto
f861abadfe Merge branch 'portable-zu' 2015-07-12 19:56:19 +02:00
Matthew Plough
768f8be31c Fix #3094 - improve use of portable size_t/ssize_t format specifiers.
The header src/cc-compat.h defines portable format specifiers PRIuZ, PRIdZ, and PRIxZ. The original report highlighted the need to use these specifiers in examples/network/fetch.c.  For this commit, I checked all C source and header files not in deps/ and transitioned to the appropriate format specifier where appropriate.
2015-07-12 19:55:19 +02:00
Carlos Martín Nieto
01d0c02dba refdb: delete a ref's reflog upon deletion
Removing a reflog upon ref deletion is something which only some
backends might wish to do. Backends which are database-backed may wish
to archive a reflog, log-based ones may not need to do anything.
2015-07-12 19:08:06 +02:00
Carlos Martín Nieto
247d27c2c6 index: allow add_bypath to update submodules
Similarly to how git itself does it, allow the index update operation to
stage a change in a submodule's HEAD.
2015-07-12 12:11:22 +02:00
Carlos Martín Nieto
0d98af0911 blob: fail to create a blob from a dir with EDIRECTORY
This also affects `git_index_add_bypath()` by providing a better error
message and a specific error code when a directory is passed.
2015-07-12 12:11:22 +02:00
Carlos Martín Nieto
a34c4f8dce submdule: reproduce double-reporting of a submodule in foreach
When we rename a submodule, we should be merging two sets of information
based on whether their path is the same. We currently only deduplicate
on equal name, which causes us to double-report.
2015-07-11 13:32:57 +02:00
Edward Thomson
9a99ca7b21 wildcard filters: move CHANGELOG message to 0.23+1 2015-07-10 09:53:30 -05:00
Edward Thomson
bae467aec4 wildcard filters: clean up some warnings in tests 2015-07-10 09:53:29 -05:00
Carlos Martín Nieto
9847d80ddc Merge pull request #3281 from ethomson/wildcard_filters
filters: custom filters with wildcard attributes
2015-07-09 18:21:31 +02:00
Edward Thomson
43ce8cb52e revert: correct test that added trailing newline 2015-07-07 17:01:49 -05:00
Edward Thomson
ae8f7260ec merge_files: don't add trailing newlines
When invoked with three files that each lack a trailing newline,
the merge result should also lack a trailing newline.
2015-07-07 17:01:48 -05:00
Carlos Martín Nieto
3704ac35d3 Merge pull request #3277 from git-up/git_diff_index_to_index
Added git_diff_index_to_index()
2015-07-07 12:38:47 +02:00
Carlos Martín Nieto
ea445e0602 Merge pull request #3288 from ethomson/getenv
git__getenv: utf-8 aware env reader
2015-07-07 00:48:17 +02:00
Carlos Martín Nieto
3c831113ca Merge pull request #3202 from jeffhostetler/windows_stack_trace
Stacktraces with CRTDBG memory leaks on Windows
2015-07-06 19:04:48 +02:00
Edward Thomson
e069c621bd git__getenv: utf-8 aware env reader
Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere.
Make `cl_getenv` use this to keep consistent memory handling around
return values (free everywhere, as opposed to only some platforms).
2015-07-02 16:35:43 +00:00
Carlos Martín Nieto
f034c8518e Merge pull request #3287 from ethomson/filter_test_cleanup
filter::stream: free the filter sanely
2015-07-02 17:55:16 +02:00
Edward Thomson
79306d8d59 filter::stream: free the filter sanely
Don't use the filter's free callback to free the actual data structure
holding the filter, as we may not always actually initialize it (the
test may be skipped).
2015-07-02 10:21:48 -05:00
Carlos Martín Nieto
e8e848a8da submodule: add failing test for loading the wrong submodule
When two submodules are fairly similar, we may end up loading the wrong
one.
2015-07-01 21:14:55 +02:00
Carlos Martín Nieto
34065968ed submodule: completely remove reload_all
The function was removed, but its declaration and changelog entry about
its removal were forgotten.

The comment in the test doesn't make any sense as the function doesn't
exist anymore, so get rid of it as well.
2015-07-01 17:49:07 +02:00
Edward Thomson
63924435a1 filters: custom filters with wildcard attributes
Allow custom filters with wildcard attributes, so that clients
can support some random `filter=foo` in a .gitattributes and look
up the corresponding smudge/clean commands in the configuration file.
2015-07-01 09:40:11 -05:00
Pierre-Olivier Latour
ccef5adb63 Added git_diff_index_to_index() 2015-06-30 10:03:32 -07:00
Edward Thomson
eb29292aed index tests: add eol to avoid compiler warning 2015-06-30 14:31:07 +00:00
Edward Thomson
504b069701 checkout test: mark unused vars 2015-06-30 14:31:07 +00:00
Carlos Martín Nieto
7bfdd1c2d2 Merge pull request #3270 from ethomson/warnings2
Remove some warnings
2015-06-30 10:21:06 +02:00
Edward Thomson
64c415c2ae checkout test: check getcwd return value 2015-06-29 22:34:00 +00:00
Edward Thomson
eadf37151b clar: test chdir 2015-06-29 22:13:40 +00:00
Edward Thomson
d88abb8949 filter test: pass base type 2015-06-29 22:13:40 +00:00
Edward Thomson
0175971e91 stash: const up conflict params 2015-06-29 21:23:09 +00:00
Edward Thomson
2cf33fee89 index test: include repository.h for decl 2015-06-29 21:23:09 +00:00
Jeff Hostetler
93b4272895 Include stacktrace summary in memory leak output. 2015-06-29 16:39:11 -04:00
Carlos Martín Nieto
c28a5c972d submodule: remove trailing slashes from submodule paths
We allow looking up a submodule by path, but we lost the path
normalisation during the recent changes. Bring it back.
2015-06-29 21:10:47 +02:00
Carlos Martín Nieto
fa399750c6 Merge pull request #3265 from libgit2/leaks
Plug a bunch of leaks
2015-06-27 21:26:27 +02:00
Carlos Martín Nieto
92ec9ed328 Merge pull request #3260 from ethomson/apply_with_reflog_indices
stash: test we apply using reflog-like indices
2015-06-27 21:15:00 +02:00
Carlos Martín Nieto
24fa21f38e index, iterator, fetchhead: plug leaks 2015-06-26 19:00:33 +02:00
Carlos Martín Nieto
afd8a94ee7 checkout: plug a few leaks 2015-06-26 18:49:39 +02:00
Carlos Martín Nieto
9568660f62 diff: fix leaks in diff printing 2015-06-26 18:31:39 +02:00
Carlos Martín Nieto
cfafeb843d Merge pull request #3263 from git-up/fixes
Fixes
2015-06-26 18:11:05 +02:00
Edward Thomson
ee6eed5188 stash: test we apply using reflog-like indices 2015-06-26 11:48:48 -04:00
Carlos Martín Nieto
354268ca48 Merge pull request #3259 from ethomson/stash_apply_argh
Stash apply: stage new files even when not updating the index
2015-06-26 17:46:35 +02:00
Pierre-Olivier Latour
492851c9a2 Removed unused variables 2015-06-26 08:18:06 -07:00
Vicent Marti
13e5e344a6 test-diff-blob: Pass proper nibble sizes 2015-06-26 16:52:26 +02:00
Vicent Marti
a2f8d1ae2b revparse: Add test to make sure this doesn't regress 2015-06-26 16:48:58 +02:00
Edward Thomson
619423f238 diff: test we don't update index unnecessarily
Test that workdir diffs, when presented with UPDATE_INDEX, only
write the index when they actually make a change.
2015-06-26 02:00:20 -04:00
Edward Thomson
c0280bdd15 Merge pull request #3255 from libgit2/cmn/rename-unspecified
Rename FALLBACK to UNSPECIFIED
2015-06-25 18:55:48 -04:00
Edward Thomson
b7f5cb8dd7 stash: stage new files when unstashing them
Files that were new (staged additions) in the stash tree should
be staged when unstashing, even when not applying the index.
2015-06-25 18:34:38 -04:00
Edward Thomson
82b1c93d08 stash: don't allow apply with staged changes 2015-06-25 18:34:36 -04:00
Edward Thomson
1db6a0ab52 stash apply: add a newly staged file to tests 2015-06-25 18:33:56 -04:00
Edward Thomson
3b66c6a397 Merge pull request #3256 from libgit2/cmn/fetch-spec-fetchhead
remote: insert refspecs with no rhs in FETCH_HEAD
2015-06-25 15:36:53 -04:00
Edward Thomson
87987fd1e0 Merge pull request #3246 from libgit2/cmn/dont-grow-borrowed
Don't allow growing borrowed buffers
2015-06-25 15:26:43 -04:00
Carlos Martín Nieto
23aa7c9037 remote: insert refspecs with no rhs in FETCH_HEAD
When a refspec contains no rhs and thus won't cause an explicit update,
we skip all the logic, but that means that we don't update FETCH_HEAD
with it, which is what the implicit rhs is.

Add another bit of logic which puts those remote heads in the list of
updates so we put them into FETCH_HEAD.
2015-06-25 13:40:38 +02:00
Carlos Martín Nieto
c2418f4613 Rename FALLBACK to UNSPECIFIED
Fallback describes the mechanism, while unspecified explains what the
user is thinking.
2015-06-25 12:48:44 +02:00
Carlos Martín Nieto
a65992355d buffer: make use of EINVALID for growing a borrowed buffer
This explains more closely what happens. While here, set an error
message.
2015-06-24 23:49:10 +02:00
Carlos Martín Nieto
caab22c0d4 buffer: don't allow growing borrowed buffers
When we don't own a buffer (asize=0) we currently allow the usage of
grow to copy the memory into a buffer we do own. This muddles the
meaning of grow, and lets us be a bit cavalier with ownership semantics.

Don't allow this any more. Usage of grow should be restricted to buffers
which we know own their own memory. If unsure, we must not attempt to
modify it.
2015-06-24 23:49:10 +02:00
Carlos Martín Nieto
daacf96d10 Merge pull request #3097 from libgit2/cmn/submodule-config-state
Remove run-time configuration settings from submodules
2015-06-24 23:34:40 +02:00
Carlos Martín Nieto
9d5efab89f Merge pull request #3254 from ethomson/diff-binary-patch
Handle binary DIFFABLEness properly
2015-06-24 21:13:23 +02:00
Carlos Martín Nieto
c2f274c69e Merge pull request #3250 from ethomson/stash
Stash workdir correctly when added in the index, modified in the workdir
2015-06-24 19:47:34 +02:00
Edward Thomson
ba8fb7c46a diff::binary tests: empty diff when forced binary
Ensure that even when we're forcing a binary diff that we do not
assume that there *is* a diff.  There should be an empty diff for
no change.
2015-06-24 11:39:59 -04:00
Carlos Martín Nieto
76633215d1 binary diff: test that the diff and patch otputs are the same
We test the generation of the textual patch via the patch function,
which are just one of two possibilities to get the output.

Add a second patch generation via the diff function to make sure both
outputs are in sync.
2015-06-24 14:33:02 +02:00
Pierre-Olivier Latour
8113056c7a Fixed Xcode 6.1 build warnings 2015-06-23 20:57:09 -07:00
Edward Thomson
cc605e73ac Merge pull request #3222 from git-up/conflicted
Fixed GIT_DELTA_CONFLICTED not returned in some cases
2015-06-23 23:52:03 -04:00
Edward Thomson
bd670abd23 Merge pull request #3226 from libgit2/cmn/racy-diff-again
racy-git, the missing link
2015-06-23 23:30:58 -04:00
Edward Thomson
14304b0e87 stash tests: ensure we save the workdir file
Ensure that when a file is added in the index and subsequently
modified in the working directory, the stashed working directory
tree contains the actual working directory contents.
2015-06-23 18:17:24 -04:00
Carlos Martín Nieto
16c73d3804 repository: check the format version
This is something we do on re-init but not when opening a
repository. This hasn't particularly mattered up to now as the version
has been 0 ever since the first release of git, but the times, they're
a-changing and we will soon see version 1 in the wild. We need to make
sure we don't open those.
2015-06-23 20:44:27 +02:00
Pierre-Olivier Latour
8d8a2eefef Fixed GIT_DELTA_CONFLICTED not returned in some cases
If an index entry for a file that is not in HEAD is in conflicted state,
when diffing HEAD with the index, the status field of the corresponding git_diff_delta was incorrectly reported as GIT_DELTA_ADDED instead of GIT_DELTA_CONFLICTED.

This was due to handle_unmatched_new_item() initially setting the status
to GIT_DELTA_CONFLICTED but then overriding it later with GIT_DELTA_ADDED.
2015-06-23 07:48:26 -07:00
Pierre-Olivier Latour
cb63e7e897 Explicitly handle GIT_DELTA_CONFLICTED in git_diff_merge()
This fixes a bug where if a file was in conflicted state in either diff,
it would not always remain in conflicted state in the merged diff.
2015-06-22 21:37:41 -07:00
Edward Thomson
1e46d54584 crlf tests: ensure that Unix obeys autocrlf=true
All platforms do terrible, horrible, no good, very bad translation
when core.autocrlf=true.  It's not just Windows!
2015-06-22 12:00:26 -04:00
Edward Thomson
8293c8f9a3 git_buf_text_lf_to_crlf: allow mixed line endings
Allow files to have mixed line endings instead of skipping processing
on them.
2015-06-22 12:00:23 -04:00
Edward Thomson
71686ddca6 clar: support hierarchical test resource data
Support hierarchical test resource data, such that you can have
`tests/resources/foo/bar` and move the `bar` directory in as
a fixture.

Calling `cl_fixture_sandbox` on a path that is not directly beneath
the test resources directory succeeds, placing that directory into
the test fixture.  (For example, `cl_fixture_sandbox("foo/bar")`
will sandbox the `foo/bar` directory as `bar`).

Add support for cleaning up directories created this way, by only
cleaning up the basename (in this example, `bar`) from the fixture
directory.
2015-06-22 12:00:15 -04:00
Edward Thomson
e774fa6c0b crlf tests: posix known-good data
A corpus of files checked out with Git (Linux, 1.9.1) to ensure that
produce identical data when checking out using a CRLF filter.
2015-06-22 12:00:11 -04:00
Edward Thomson
4ebe320a31 crlf tests: windows known-good data
A corpus of files checked out with Git for Windows (2.4.1.windows.1)
to ensure that we produce identical data when checking out using a
CRLF filter.
2015-06-22 12:00:06 -04:00
Edward Thomson
3d92b9abaa crlf tests: use known-good data produced by git
Given a variety of combinations of core.autocrlf settings and
attributes settings, test that we check out data into the working
directory the same as a known-good test resource created by git.git.
2015-06-22 12:00:02 -04:00
Edward Thomson
bf8c0a9b91 crlf: script to generate expected crlf data
Include a shell script that will generate the expected CRLF data,
calling git.git to capture its output as a test resource for the
current platform.
2015-06-22 11:59:58 -04:00
Edward Thomson
bd5e59ee72 crlf: include utf8 resources in master branch
Include the UTF8 and UTF8 BOM tests in the master crlf test
branch for completeness.
2015-06-22 11:59:54 -04:00
Edward Thomson
84f8f50046 crlf: include additional test resources
Include additional test data for CRLF tests: files with mixed
line endings and binary files.
2015-06-22 11:59:50 -04:00
Carlos Martín Nieto
0496330004 submodule: test unsetting config options
In addition to mapping enums to strings in the configuration, we need to
know to delete the configuration option when given the "none" or "no"
option.
2015-06-22 17:02:56 +02:00
Carlos Martín Nieto
4536574acc submodule: test more accurately for non-existence
The current code will always fail, but only because it's asking for a
string on a live config. Take a snapshot and make sure we fail with
ENOTFOUND instead of any old error.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
adb58f7d64 submodule: fix potential leak in the tests 2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
961861fafa submodule: get rid of _save()
We no longer have any setters which affect an instance, so
`git_submodule_save()` is no longer relevant.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
d6073b30f3 submodule: make _set_url() affect the configuration
With this one, we can get rid of the edit_and_save test.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
486ba4cdd3 submodule: make _set_branch() affect the configuration 2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
4e63642321 submodule: make _set_update_fetch_recurse_submodules() affect the config
Similarly to the other ones. In this test we copy over testing
`RECURSE_YES` which shows an error in our handling of the `YES` variant
which we may have to port to the rest.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
e8a39f8ed1 submodule: make _set_update() affect the configuration
Moving on with the removal of runtime-changing variables, the update
setting for a remote is whatever it was when it was looked up.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
c6f489c964 submodule: add an ignore option to status
This lets us specify in the status call which ignore rules we want to
use (optionally falling back to whatever the submodule has in its
configuration).

This removes one of the reasons for having `_set_ignore()` set the value
in-memory. We re-use the `IGNORE_RESET` value for this as it is no
longer relevant but has a similar purpose to `IGNORE_FALLBACK`.

Similarly, we remove `IGNORE_DEFAULT` which does not have use outside of
initializers and move that to fall back to the configuration as well.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
64bbd47a32 submodule: don't let status change an existing instance
As submodules are becomes more like values, we should not let a status
check to update its properties. Instead of taking a submodule, have
status take a repo and submodule name.
2015-06-22 17:02:55 +02:00