Commit Graph

1970 Commits

Author SHA1 Message Date
Edward Thomson
9fd4c9c867 Merge pull request #3366 from libgit2/cmn/index-hashmap
Use a hashmap for path-based lookups in the index
2015-09-06 10:50:22 -04:00
Carlos Martín Nieto
d83b2e9f51 filebuf: follow symlinks when creating a lock file
We create a lockfile to update files under GIT_DIR. Sometimes these
files are actually located elsewhere and a symlink takes their place. In
that case we should lock and update the file at its final location
rather than overwrite the symlink.
2015-09-05 16:43:49 +02:00
Leo Yang
c097f7173d New API: git_index_find_prefix
Find the first index entry matching a prefix.
2015-09-04 12:24:36 -04:00
Carlos Martín Nieto
21e7015ca3 Merge pull request #3402 from ethomson/faster_diff
Provide path matching in the iterators (for faster diffs)
2015-09-01 02:26:11 +02:00
Edward Thomson
03210cfa00 iterator test: handle case (in)sensitivity 2015-08-31 12:16:16 -04:00
Edward Thomson
4d19bced3f iterator test: use new iter opts in fifo test 2015-08-31 11:48:12 -04:00
Edward Thomson
d53c888069 iterator: saner pathlist matching for idx iterator
Some nicer refactoring for index iteration walks.

The index iterator doesn't binary search through the pathlist space,
since it lacks directory entries, and would have to binary search
each index entry and all its parents (eg, when presented with an index
entry of `foo/bar/file.c`, you would have to look in the pathlist for
`foo/bar/file.c`, `foo/bar` and `foo`).  Since the index entries and the
pathlist are both nicely sorted, we walk the index entries in lockstep
with the pathlist like we do for other iteration/diff/merge walks.
2015-08-31 11:48:06 -04:00
Edward Thomson
71ef639e5f status test: brackets are now literal 2015-08-30 18:57:06 -04:00
Edward Thomson
1af84271dd tree_iterator: use a pathlist 2015-08-30 18:55:18 -04:00
Edward Thomson
4a0dbeb0d3 diff: use new iterator pathlist handling
When using literal pathspecs in diff with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`
turn on the faster iterator pathlist handling.

Updates iterator pathspecs to include directory prefixes (eg, `foo/`)
for compatibility with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`.
2015-08-30 17:06:26 -04:00
Edward Thomson
3273ab3f0b diff: better document GIT_DIFF_PATHSPEC_DISABLE
Document that `GIT_DIFF_PATHSPEC_DISABLE` is not necessarily about
explicit path matching, but also includes matching of directory
names.  Enforce this in a test.
2015-08-28 20:45:08 -04:00
Edward Thomson
aa06ecaf5b Merge pull request #3352 from ethomson/hidden
win32: ensure hidden files can be staged
2015-08-28 19:30:08 -04:00
Edward Thomson
6c9352bf30 iterator: sort subdirs properly with pathlist
When given a pathlist, don't assume that directories sort before
files.  Walk through any list of entries sorting before us to make
sure that we've exhausted all entries that *aren't* directories.

Eg, if we're searching for 'foo/bar', and we have a 'foo.c', keep
advancing the pathlist to keep looking for an entry prefixed with
'foo/'.
2015-08-28 18:40:02 -04:00
Edward Thomson
ef206124de Move filelist into the iterator handling itself. 2015-08-28 18:39:52 -04:00
Edward Thomson
ed1c64464a iterator: use an options struct instead of args 2015-08-28 18:39:47 -04:00
Carlos Martín Nieto
e451cd5c03 diff: don't error out on an invalid regex
When parsing user-provided regex patterns for functions, we must not
fail to provide a diff just because a pattern is not well
formed. Ignore it instead.
2015-08-15 18:46:38 +02:00
Carlos Martín Nieto
c232d6c32d index: add tests around case switching
We were missing tests for switching the case-sensitivity of an index
in-memory and then looking up entries in it.
2015-08-14 21:06:51 +02:00
Edward Thomson
9f1af7f279 Merge pull request #3168 from libgit2/cmn/config-tx
Locking and transactional/atomic updates for config
2015-08-13 10:22:50 -07:00
Carlos Martín Nieto
5340d63d38 config: perform unlocking via git_transaction
This makes the API for commiting or discarding changes the same as for
references.
2015-08-12 04:09:38 +02:00
Carlos Martín Nieto
36f784b538 config: expose locking via the main API
This lock/unlock pair allows for the cller to lock a configuration file
to avoid concurrent operations.

It also allows for a transactional approach to updating a configuration
file. If multiple updates must be made atomically, they can be done
while the config is locked.
2015-08-12 04:09:38 +02:00
Carlos Martín Nieto
b166703964 config: implement basic transactional support
When a configuration file is locked, any updates made to it will be done
to the in-memory copy of the file. This allows for multiple updates to
happen while we hold the lock, preventing races during complex
config-file manipulation.
2015-08-12 04:09:09 +02:00
Carlos Martín Nieto
a879276783 remote: add failing test for a mirror refspec
While we download the remote's remote-tracking branches, we don't
download the tag. This points to the tag auto-follow rules interfering
with the refspec.
2015-08-11 20:44:19 +02:00
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
Carlos Martín Nieto
5a9fc6c83c submodule: make set_ignore() affect the configuration
Instead of affecting a particular instance, make it change the
configuration.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
dfda2f68ea submodule: remove the per-repo cache
Having this cache and giving them out goes against our multithreading
guarantees and it makes it impossible to use submodules in a
multi-threaded environment, as any thread can ask for a refresh which
may reallocate some string in the submodule struct which we've accessed
in a different one via a getter.

This makes the submodules behave more like remotes, where each object is
created upon request and not shared except explicitly by the user. This
means that some tests won't pass yet, as they assume they can affect the
submodule objects in the cache and that will affect later operations.
2015-06-22 17:02:54 +02:00
Carlos Martín Nieto
6e611f7c3c index: add a diff test for smudging a file which becomes empty
Even though the file is empty and thus the size in the entry matches, we
should be able to detect it as a difference.
2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
27133caf3c tests: move racy tests to the index
They fit there much better, even though we often check by diffing, it's
about the behaviour of the index.
2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
5b05f95424 merge: work around write-side racy protection when hacking the index
As we attempt to replicate a situation in which an older checkout has
put a file on disk with different filtering settings from us, set the
timestamp on the entry and file to a second before we're performing the
operation so the entry in the index counts as old.

This way we can test that we're not looking at the on-disk file when the
index has the entry and we detect it as clean.
2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
a3f42fe8e4 commit: allow retrieving an arbitrary header field
This allows the user to look up fields which we don't parse in libgit2,
and allows them to access gpgsig or mergetag fields if they wish to
check the signature.
2015-06-22 15:56:31 +02:00
Carlos Martín Nieto
26432a9c62 tests: set racy times manually 2015-06-22 12:47:30 +02:00
Carlos Martín Nieto
6c5eaead49 tests: plug leaks in the racy test 2015-06-22 12:47:30 +02:00
Carlos Martín Nieto
ff47537557 diff: check files with the same or newer timestamps
When a file on the workdir has the same or a newer timestamp than the
index, we need to perform a full check of the contents, as the update of
the file may have happened just after we wrote the index.

The iterator changes are such that we can reach inside the workdir
iterator from the diff, though it may be better to have an accessor
instead of moving these structs into the header.
2015-06-22 12:47:30 +02:00
Edward Thomson
fc6568021c status: test that symlinks don't lose their mode
Test to ensure that when status updates an index, it does not alter
the original mode for file types that are not supported (eg, symlinks
on Windows).
2015-06-20 15:37:32 -04:00
Edward Thomson
9018529b4e Merge pull request #3238 from git-up/double_free
Fixed index being double-freed in stash tests
2015-06-20 14:34:34 -04:00
Edward Thomson
883cb642cb Merge pull request #3236 from libgit2/cmn/index-checksum
Use the checksum to check whether an index has been modified
2015-06-20 14:05:02 -04:00
Pierre-Olivier Latour
07ea3a7f57 Fixed index being double-freed in stash tests 2015-06-20 10:57:03 -07:00
Carlos Martín Nieto
863dd89abf tests: tick over five seconds instead of one
When ticking over one second, it can happen that the actual time ticks
over the same second between the time that we undermine our own race
protections and the time in which we perform the index update. Such
timing would make the time in the entries match the index' timestamp and
we have not gained anything.

Ticking over five seconds makes it so that if real-time rolls over that
second, our index is still ahead. This is still suboptimal as we're
dealing with timing, but five seconds should be long enough for any
reasonable test runner to finish the tests.
2015-06-20 10:46:10 +02:00
Carlos Martín Nieto
46c84c7260 index: user a better assertion when comparing sizes
This will tell us which numbers we were trying to compare, rather than
just telling us that they're different.
2015-06-19 21:56:42 +02:00
Pierre-Olivier Latour
85a5e8ebe1 Fixed Xcode 6.1 build warnings 2015-06-17 09:00:23 -07:00
Jeff Hostetler
534d136da3 Fix memory leak in tests/network/refspecs.c 2015-06-17 08:52:28 -04:00
Carlos Martín Nieto
a56db99234 Merge pull request #3219 from libgit2/cmn/racy-diff
Zero out racily-clean entries' file_size
2015-06-17 08:15:49 +02:00
Edward Thomson
fef5344c50 merge::workdir::dirty: tick idx to defeat racy-git 2015-06-16 16:39:13 -04:00
Edward Thomson
121c3171e5 Introduce p_utimes and p_futimes
Provide functionality to set the time on a filesystem entry,
using utimes or futimes on POSIX type systems or SetFileTime
on Win32.
2015-06-16 15:32:02 -04:00
Edward Thomson
5f83758fa3 Merge pull request #3209 from libgit2/cmn/double-author
commit: ignore multiple author fields
2015-06-16 10:40:46 -04:00
Carlos Martín Nieto
e44abe16bd tests: tick the index when we count OID calculations
These tests want to test that we don't recalculate entries which match
the index already. This is however something we force when truncating
racily-clean entries.

Tick the index forward as we know that we don't perform the
modifications which the racily-clean code is trying to avoid.
2015-06-16 08:51:45 +02:00
Carlos Martín Nieto
c4e6ab5f23 crlf: tick the index forward to work around racy-git behaviour
In order to avoid racy-git, we zero out the file size for entries with
the same timestamp as the index (or during the initial checkout). This
is the case in a couple of crlf tests, as the code is fast enough to do
everything in the same second.

As we know that we do not perform the modification just after writing
out the index, which is what this is designed to work around, tick the
mtime of the index file such that it doesn't agree with the files
anymore, and we do not zero out these entries.
2015-06-16 08:40:45 +02:00
Carlos Martín Nieto
77596fcfd7 diff: add failing test for racy-git in the index
We update the index and then immediately change the contents of the
file. This makes the diff think there are no changes, as the timestamp
of the file agrees with the cached data. This is however a bug, as the
file has obviously changed contents.

The test is a bit fragile, as it assumes that the index writing and the
following modification of the file happen in the same second, but it's
enough to show the issue.
2015-06-16 08:40:45 +02:00
Pierre-Olivier Latour
0f4d9c0367 Fixed Xcode 6.1 build warnings 2015-06-15 09:55:12 -07:00
Carlos Martín Nieto
d4723c89d4 Merge pull request #3177 from ethomson/binary_diff
Binary diffs: store deltas in the diff structure, include binary data in diff callbacks
2015-06-15 08:17:45 +02:00
Carlos Martín Nieto
ae22ef0e5a Merge pull request #3217 from jeffhostetler/leak_checkout_icase
Fix leaks in tests/checkout/icase
2015-06-15 08:09:21 +02:00
Jeff Hostetler
26d5c0b823 Fix leaks in tests/checkout/icase 2015-06-12 09:28:47 -07:00
Edward Thomson
391281ae34 binary diff: test binary blob to blob tests 2015-06-12 09:39:29 -04:00
Edward Thomson
8147b1aff5 diff: introduce binary diff callbacks
Introduce a new binary diff callback to provide the actual binary
delta contents to callers.  Create this data from the diff contents
(instead of directly from the ODB) to support binary diffs including
the workdir, not just things coming out of the ODB.
2015-06-12 09:39:20 -04:00
Edward Thomson
ac7012a81f binary diff: test index->workdir binary diffs 2015-06-12 09:24:59 -04:00
Carlos Martín Nieto
352ee17152 clone: set the credentials callback during testing 2015-06-12 12:45:49 +02:00
Carlos Martín Nieto
0f69b41d2e push: pass the callbacks during setup as well
We need to pass these options in order to have the credentials callback
set.
2015-06-12 12:33:55 +02:00
Carlos Martín Nieto
65d69fe854 commit: ignore multiple author fields
Some tools create multiple author fields. git is rather lax when parsing
them, although fsck does complain about them. This means that they exist
in the wild.

As it's not too taxing to check for them, and there shouldn't be a
noticeable slowdown when dealing with correct commits, add logic to skip
over these extra fields when parsing the commit.
2015-06-11 08:24:58 +02:00
Edward Thomson
2eecc2886b Introduce git_filter_list_contains
`git_filter_list_contains` can be used to query a filter list to
determine if a given filter will be run.
2015-06-10 14:43:49 -04:00
Carlos Martín Nieto
82a7a24cf4 Merge pull request #3165 from ethomson/downcase
Downcase
2015-06-08 15:22:01 +02:00
Carlos Martín Nieto
b6011e296e Merge pull request #3185 from libgit2/cmn/foreach-cancel-loose
path: error out if the callback returns an error
2015-06-07 15:10:28 +02:00
Carlos Martín Nieto
8da4404705 path: error out if the callback returns an error
When the callback returns an error, we should stop immediately. This
broke when trying to make sure we pass specific errors up the chain.

This broke cancelling out of the loose backend's foreach.
2015-06-06 03:55:28 +02:00
Pierre-Olivier Latour
9f3c18e2ac Fixed build warnings on Xcode 6.1 2015-06-02 11:49:38 -07:00
Patrick Steinhardt
9e88a823f6 remote: test insteadOf for anonymous remotes 2015-05-31 13:26:05 +02:00
Patrick Steinhardt
ec0c4c4001 remote: apply insteadOf configuration.
A remote's URLs are now modified according to the url.*.insteadOf
and url.*.pushInsteadOf configurations. This allows a user to
replace URL prefixes by setting the corresponding keys. E.g.
"url.foo.insteadOf = bar" would replace the prefix "bar" with the
new prefix "foo".
2015-05-31 13:21:53 +02:00
Edward Thomson
bad33a5dfb git__tolower: test that some non-ASCII downcasing isn't 2015-05-29 18:16:51 -04:00
Edward Thomson
006548da91 git__strcasecmp: treat input bytes as unsigned
Treat input bytes as unsigned before doing arithmetic on them,
lest we look at some non-ASCII byte (like a UTF-8 character) as a
negative value and perform the comparison incorrectly.
2015-05-29 16:07:51 -04:00
Carlos Martín Nieto
2c8550f040 Merge pull request #3157 from mgorny/ssh_memory_auth
Support getting SSH keys from memory, pt. 2
2015-05-29 19:38:11 +02:00
Edward Thomson
885b94aac0 Rename GIT_EMERGECONFLICT to GIT_ECONFLICT
We do not error on "merge conflicts"; on the contrary, merge conflicts
are a normal part of merging.  We only error on "checkout conflicts",
where a change exists in the index or the working directory that would
otherwise be overwritten by performing the checkout.

This *may* happen during merge (after the production of the new index
that we're going to checkout) but it could happen during any checkout.
2015-05-29 09:55:09 -04:00
Carlos Martín Nieto
ff8d635adb Merge pull request #3139 from ethomson/diff_conflicts
Include conflicts when diffing
2015-05-28 18:45:57 +02:00
Edward Thomson
fb92b48d54 Merge pull request #3149 from libgit2/cmn/upstream-matching-push
Fill the pointers for matching refspecs
2015-05-28 10:13:07 -04:00
Carlos Martín Nieto
2b92283221 Merge pull request #3127 from libgit2/cmn/remote-fixups
Tackle remote API issues from bindings
2015-05-28 16:09:17 +02:00
Edward Thomson
666ae18821 git_index_add_all: test that conflicts are handled
When confronted with a conflict in the index, `git_index_add_all`
should stage the working directory copy.  If there is no file in the
working directory, the conflict should simply be removed.
2015-05-28 09:47:43 -04:00
Edward Thomson
1c4b5cee00 Introduce cl_git_sandbox_init_new()
cl_git_sandbox_init_new() will create a clar temp directory and
initialize a new repository at that location.
2015-05-28 09:47:39 -04:00
Edward Thomson
9f545b9d71 introduce git_index_entry_is_conflict
It's not always obvious the mapping between stage level and
conflict-ness.  More importantly, this can lead otherwise sane
people to write constructs like `if (!git_index_entry_stage(entry))`,
which (while technically correct) is unreadable.

Provide a nice method to help avoid such messy thinking.
2015-05-28 09:47:31 -04:00
Edward Thomson
2f1080ea04 conflict tests: use GIT_IDXENTRY_STAGE_SET 2015-05-28 09:44:22 -04:00
Edward Thomson
191e97a02b diff conflicts: don't include incorrect ID
Since a diff entry only concerns a single entry, zero the information
for the index side of a conflict.  (The index entry would otherwise
erroneously include the lowest-stage index entry - generally the
ancestor of a conflict.)

Test that during status, the index side of the conflict is empty.
2015-05-28 09:44:18 -04:00
Edward Thomson
b22369efa2 diff conflicts: test index to workdir w/ conflicts 2015-05-28 09:44:14 -04:00
Edward Thomson
bb815157da diff conflicts: add tests for tree to index 2015-05-28 09:44:10 -04:00
Edward Thomson
7c94801400 diff/status: introduce conflicts
When diffing against an index, return a new `GIT_DELTA_CONFLICTED`
delta type for items that are conflicted.  For a single file path,
only one delta will be produced (despite the fact that there are
multiple entries in the index).

Index iterators now have the (optional) ability to return conflicts
in the index.  Prior to this change, they would be omitted, and callers
(like diff) would omit conflicted index entries entirely.
2015-05-28 09:44:02 -04:00
Edward Thomson
d67f270e58 index: validate mode of new conflicts 2015-05-28 09:43:57 -04:00
Edward Thomson
ecd60a56eb conflicts: when adding conflicts, remove staged
When adding a conflict for some path, remove the staged entry.
Otherwise, an illegal index (with both stage 0 and high-stage
entries) would result.
2015-05-28 09:43:49 -04:00
Carlos Martín Nieto
c6e942fb3d remote: validate refspecs before adding to config
When we moved from acting on the instance to acting on the
configuration, we dropped the validation of the passed refspec, which
can lead to writing an invalid refspec to the configuration. Bring that
validation back.
2015-05-28 15:32:20 +02:00
Carlos Martín Nieto
ae5b93629c remote: remove fetch parameter from create_anonymous
An anonymous remote is not configured and cannot therefore have
configured refspecs. Remove the parameter which adds this from the
constructor.
2015-05-28 15:32:20 +02:00
Michał Górny
8085adf82c test: Add a test for in-memory SSH private key cred_cb 2015-05-27 20:36:53 +02:00
Colomban Wendling
1ecbcd8e51 Fix ident replacement to match Git behavior
Git inserts a space after the SHA1 (as of 2.1.4 at least), so do the
same.
2015-05-26 19:56:06 +02:00
Carlos Martín Nieto
5014fe95f5 branch: error out if we cannot find the remote
When we look for which remote corresponds to a remote-tracking branch,
we look in the refspecs to see which ones matches. If none do, we should
abort. We currently ignore the error message from this operation, so
let's not do that anymore.

As part of the test we're writing, let's test for the expected behaviour
if we cannot find a refspec which tells us what the remote-tracking
branch for a remote would look like.
2015-05-22 12:31:39 +02:00
Carlos Martín Nieto
7cd4ba1b17 refspec: make sure matching refspecs have src, dst and input strings
When we find out that we're dealing with a matching refspec, we set the
flag and return immediately. This leaves the strings as NULL, which
breaks the contract.

Assign these pointers to a string with the correct values.
2015-05-22 12:11:42 +02:00
Carlos Martín Nieto
6675aaba88 Merge pull request #3146 from ethomson/add_untracked_files
index_add_all: include untracked files in new subdirs
2015-05-21 04:58:16 +02:00
Edward Thomson
fa9a969d80 index_add_all: include untracked files in new subdirs 2015-05-20 20:05:55 -04:00
Carlos Martín Nieto
2c57114f11 ignore: clear the error when matching a pattern negation
When we discover that we want to keep a negative rule, make sure to
clear the error variable, as it we otherwise return whatever was left by
the previous loop iteration.
2015-05-20 21:49:02 +02:00
Edward Thomson
acc573cba3 Merge pull request #3109 from libgit2/cmn/index-use-diff
Use a diff for iteration in index_update_all and index_add_all
2015-05-19 14:12:40 -04:00
Carlos Martín Nieto
7b5ce2e5c4 clone: don't rely on auto-saving for single-branch
The code used to rely on the clone code calling the remote's save, which
does not happen anymore, meaning that the configuration settings the
remote expected were not being written to disk.

The run-time configuration was still being affected, so the right branch
was being cloned. The tests continued to pass as we did not check for
the configuration entires. Fix this by creating the remote with the
single-branch refspec we want and checking for its existence in the
configuration.
2015-05-17 15:45:37 +02:00
Carlos Martín Nieto
2b2dfe80f0 index: include TYPECHANGE in the diff
Without this option, we would not be able to catch exec bit changes.
2015-05-14 15:23:12 +02:00
Carlos Martín Nieto
041ad7dbd6 push: add tests for the push negotiation callback
The functionality was meged without including tests, so let's add them
now.
2015-05-14 10:34:05 +02:00
Carlos Martín Nieto
16d742ebdb Merge pull request #3119 from ethomson/ignore
Attributes: don't match files for folders
2015-05-13 21:43:58 +02:00
Edward Thomson
cd430bc786 Merge pull request #3103 from libgit2/cmn/local-push-message
Use the packbuilder in local push
2015-05-13 14:26:20 -04:00
Edward Thomson
882cc37f83 attr tests: make explicit our dir/file match tests 2015-05-13 10:56:55 -04:00
Carlos Martín Nieto
3e529e9d2d Fix a few leaks
The interesting one is the notification macro, which was returning
directly on a soft-abort instead of going through the cleanup.
2015-05-13 16:40:18 +02:00
Edward Thomson
6cd9219385 Merge pull request #3115 from libgit2/cmn/clone-submodule
submodule: add test initialising and cloning a repo
2015-05-13 09:07:15 -04:00
Carlos Martín Nieto
0bc3d56dde tests: don't push to our resources
A couple of tests use the wrong remote to push to. We did not notice up
to now because the local push would copy individual objects, and those
already existed, so it became a no-op.

Once we made local push create the packfile, it became noticeable that
there was a new packfile where it didn't belong.
2015-05-13 10:56:37 +02:00
Carlos Martín Nieto
a4b6452a6a remote: remove git_remote_save()
It has now become a no-op, so remove the function and all references to
it.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
7725499072 remote: remove live changing of refspecs
The base refspecs changing can be a cause of confusion as to what is the
current base refspec set and complicate saving the remote's
configuration.

Change `git_remote_add_{fetch,push}()` to update the configuration
instead of an instance.

This finally makes `git_remote_save()` a no-op, it will be removed in a
later commit.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
35a8a8c546 remote: move the tagopt setting to the fetch options
This is another option which we should not be keeping in the remote, but
is specific to each particular operation.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
3eff2a5728 remote: move the update_fetchhead setting to the options
While this will rarely be different from the default, having it in the
remote adds yet another setting it has to keep around and can affect its
behaviour. Move it to the options.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
058b753ceb remote: move the transport ctor to the callbacks
Instead of having it set in a different place from every other callback,
put it the main structure. This removes some state from the remote and
makes it behave more like clone, where the constructors are passed via
the options.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
22261344de remote: remove url and pushurl from the save logic
As a first step in removing the repository-saving logic, don't allow
chaning the url or push url from a remote object, but change the
configuration on the configuration immediately.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
8f0104ecc5 Remove the callbacks struct from the remote
Having the setting be different from calling its actions was not a great
idea and made for the sake of the wrong convenience.

Instead of that, accept either fetch options, push options or the
callbacks when dealing with the remote. The fetch options are currently
only the callbacks, but more options will be moved from setters and
getters on the remote to the options.

This does mean passing the same struct along the different functions but
the typical use-case will only call git_remote_fetch() or
git_remote_push() and so won't notice much difference.
2015-05-13 09:46:35 +02:00
Edward Thomson
9486d20336 attr test: test a file beneath ignored folder 2015-05-12 14:36:48 -04:00
Edward Thomson
97fb9ac739 attr: test that a file is not ignored for a folder
When a .gitignore specifies some folder "foo/", ensure that a file
with the same name "foo" is not ignored.
2015-05-12 14:36:45 -04:00
Edward Thomson
adad518129 attr: regression tests for ignore matching
Ensure that when examining a .gitignore in a subdirectory, we do not
erroneously apply the paths contained therein to the root of the
repository.  (Fixed in c02a0e4).
2015-05-12 14:36:41 -04:00
Carlos Martín Nieto
1e44ea97f6 submodule: add test initialising and cloning a repo
We have a few tests checking each step, but we do not yet have a test
which tests the documented workflow for creating a submodule, namely
`setup_add` followed by cloning into it, followed by `add_finalize`.

Add such a test to protect against regressions in this workflow.
2015-05-12 11:13:41 +02:00
Edward Thomson
4ea3eebf4b stash_apply: provide progress callbacks 2015-05-11 14:12:42 -04:00
Edward Thomson
19c80a6fd1 stash_apply: provide its own options structure 2015-05-11 14:12:39 -04:00
Edward Thomson
249616685e stash: test checkout notify callbacks 2015-05-11 14:12:35 -04:00
Edward Thomson
f78bb2afb3 stash: return GIT_EMERGECONFLICT on merge conflict 2015-05-11 14:12:27 -04:00
Edward Thomson
f0957589ee stash: refactor to use merge_iterators 2015-05-11 14:12:19 -04:00
Edward Thomson
d0dd3fcee7 stash apply: check out a tree, not piecewise 2015-05-11 14:12:12 -04:00
Edward Thomson
35d3976151 index: introduce git_index_read_index 2015-05-11 14:12:05 -04:00
Edward Thomson
9ebb5a3ff3 merge: merge iterators 2015-05-11 14:11:56 -04:00
Pierre-Olivier Latour
bf8dd3f53d Added git_stash_apply() and git_stash_pop() APIs 2015-05-11 14:11:53 -04:00
Carlos Martín Nieto
074d323f73 Merge pull request #3079 from ethomson/config
Configuration changes for handling multiple of the same sections
2015-05-04 15:23:40 +02:00
Edward Thomson
d6b7e40497 config: test all multivars are updated
If a multivar exists within two sections (of the same name)
then they should both be updated in a `set_multivar`.  Ensure
that this is the case.
2015-05-04 07:41:41 -05:00
Edward Thomson
0daf998de7 config: use wildcard in test instead of empty expr 2015-05-04 07:41:40 -05:00
Edward Thomson
63c0cc65bc config: cleanup some now-unused variables 2015-05-04 07:41:38 -05:00
Ryan Roden-Corrent
5a70df9436 Test setting config var under duplicate header.
Add a test that exposes a bug in config_write.
It is valid to have multiple separate headers for the same config section, but
config_write will exit after finding the first matching section in certain
situations.
This test proves that config_write will duplicate a variable that already
exists instead of overwriting it if the variable is defined under a duplicate
section header.
2015-05-04 07:41:36 -05:00
Edward Thomson
bf99390eef config: examine whole file when writing
Previously we would try to be clever when writing the configuration
file and try to stop parsing (and simply copy the rest of the old
file) when we either found the value we were trying to write,
or when we left the section that value was in, the assumption being
that there was no more work to do.

Regrettably, you can have another section with the same name later
in the file, and we must cope with that gracefully, thus we read the
whole file in order to write a new file.

Now, writing a file looks even more than reading.  Pull the config
parsing out into its own function that can be used by both reading
and writing the configuration.
2015-05-04 07:41:33 -05:00
Edward Thomson
f79c7322a9 config: test overwriting cvar in multiple regions 2015-05-04 07:41:31 -05:00
Edward Thomson
7ee61b8ee3 config: ensure we can write to an empty file 2015-05-04 07:41:30 -05:00
Edward Thomson
cd79d99a4c checkout test: better case-insensitive test on Mac
On Mac OS, `realpath` is deficient in determining the actual filename
on-disk as it will simply provide the string you gave it if that file
exists, instead of returning the filename as it exists.  Instead we
must read the directory entries for the parent directory to get the
canonical filename.
2015-05-04 07:18:30 -05:00
Edward Thomson
f286e2715d status test: always test the new file path 2015-05-04 07:18:29 -05:00
Edward Thomson
64842d8756 checkout test: only run icase on icase platform 2015-05-04 07:18:29 -05:00
Edward Thomson
05f690122e checkout: remove blocking dir when FORCEd 2015-05-04 07:18:27 -05:00
Edward Thomson
3520c97057 Revert "Always checkout with case sensitive iterator"
This reverts commit 40d791545a.
2015-05-04 07:18:27 -05:00
Edward Thomson
6dfd8506b7 checkout test: ensure we write to casechanged dir
Ensure that on a case insensitive filesystem that we can checkout
into some folder 'FOLDER' that exists on disk, even if the target
of the checkout is a different case (eg 'folder').
2015-05-04 07:18:26 -05:00
Edward Thomson
431f98070f checkout test: ignore unstaged case-changing renames
On Windows, you might sloppily rewrite a file (or have a sloppy
text editor that does it for you) and accidentally change its
case.  (eg, "README" -> "readme").  Git ignores this accidental
case changing rename during checkout and will happily write the
new content to the file despite the name change.  We should, too.
2015-05-04 07:18:25 -05:00
Carlos Martín Nieto
cfc2e56d59 Merge pull request #3087 from ethomson/pr/3054
Performance Improvements to Status on Windows
2015-05-04 11:16:52 +02:00
Edward Thomson
5c387b6c5a git_path_diriter: next shouldn't take path ptr
The _next method shouldn't take a path pointer (and a path_len
pointer) as 100% of current users use the full path and ignore
the filename.

Plus let's add some docs and a unit test.
2015-05-01 12:31:29 -04:00
Edward Thomson
07bbc045c7 git_path_dirload: use git_path_diriter 2015-05-01 12:31:09 -04:00
Edward Thomson
cbe8a61dfa Merge pull request #3059 from libgit2/cmn/negotiation-notify
[WIP/RFC] push: report the update plan to the caller
2015-05-01 11:28:54 -04:00
Tomas Paladin Volf
cf2380a623 Fixed unused warning in tests/rebase/merge.c 2015-04-30 14:17:05 +02:00
J Wyman
4c09e19a37 Improvements to ignore performance on Windows.
Minimizing the number directory and file opens, minimizes the amount of IO thus reducing the overall cost of performing ignore operations.
2015-04-28 14:24:58 -04:00
Carlos Martín Nieto
65808406bb Merge pull request #3063 from ethomson/config_validate_name
Validate configuration keys
2015-04-24 02:46:49 +02:00
Carlos Martín Nieto
24e53d2fba Rename GIT_SSL to GIT_OPENSSL
This is what it's meant all along, but now we actually have multiple
implementations, it's clearer to use the name of the library.
2015-04-23 17:39:51 +02:00
Carlos Martín Nieto
6bb54cbff3 Add a SecureTransport TLS channel
As an alternative to OpenSSL when we're on OS X. This one can actually
take advantage of stacking the streams.
2015-04-23 17:39:51 +02:00
Edward Thomson
6dc55872a8 config: ensure we can write to an empty file 2015-04-23 11:25:03 -04:00
Edward Thomson
23fb4004ed config: test that we validate the key 2015-04-23 11:24:50 -04:00
Carlos Martín Nieto
69c333f997 Merge pull request #3064 from rcorre/config-write-fix
config_write -- handle duplicate section headers when deleting entries
2015-04-23 17:23:04 +02:00
Carlos Martín Nieto
63e8b08dfc Merge branch 'attr-ignore' 2015-04-23 17:08:10 +02:00
Mike McQuaid
c6bf03b44f Add failing subdirectory gitignore attr test. 2015-04-23 17:07:37 +02:00
Edward Thomson
27fa7477b0 Merge pull request #3032 from jfultz/index-file-modes
Fix git_checkout_tree() to do index filemodes correctly on Windows.
2015-04-23 10:54:08 -04:00
cthomas
fc6f044ea3 Fix for Issue #3023 tests fail with no network
Moved offending tests from network to online so they will get skipped
when there is a lack of network connectivity:
-test_online_remotes__single_branch
-test_online_remotes__restricted_refspecs
2015-04-21 20:02:24 -04:00
Ryan Roden-Corrent
f56a417de4 Specify mock config file content in test.
Instead of using a config file in resources, include the config file content to
be tested directly in the test.
2015-04-21 14:21:52 -04:00
Ryan Roden-Corrent
a060cccc0a Unittest to validate config entry deletion bug.
Add a unittest to validate bug #3043, where a duplicate empty config header
could cause deletion of a config entry to fail silently. The bug is currently
unresolved and this test will fail.
2015-04-21 14:21:52 -04:00
Carlos Martín Nieto
7636f740b3 Merge pull request #2992 from ethomson/rebase_fixes
Rebase fixes
2015-04-21 14:38:23 +02:00
John Fultz
d3282680ed Fix index-adding functions to know when to trust filemodes.
The idea...sometimes, a filemode is user-specified via an
explicit git_index_entry.  In this case, believe the user, always.

Sometimes, it is instead built up by statting the file system.  In
those cases, go with the existing logic we have to determine
whether the file system supports all filemodes and symlinks, and
make the best guess.

On file systems which have full filemode and symlink support, this
commit should make no difference.  On others (most notably Windows),
this will fix problems things like:
* git_index_add and git_index_add_frombuffer() should be believed.
* As a consequence, git_checkout_tree should make the filemodes in
the index match the ones in the tree.
* And diffs with GIT_DIFF_UPDATE_INDEX don't write the wrong filemodes.
* And merges, and probably other downstream stuff now fixed, too.

This makes my previous changes to checkout.c unnecessary,
so they are now reverted.

Also, added a test for index_entry permissions from git_index_add
and git_index_add_frombuffer, both of which failed before these changes.
2015-04-21 02:17:23 -05:00
Edward Thomson
94c988f6d6 rebase: include checkout opts within rebase opts 2015-04-20 17:19:08 -04:00
Edward Thomson
7838235890 rebase: test checkout options for rebase 2015-04-20 16:22:59 -04:00
Edward Thomson
f3a199dd99 rebase: init and open take a rebase_options
`git_rebase_init` and `git_rebase_open` should take a
`git_rebase_options` and use it for future rebase operations on
that `rebase` object.
2015-04-20 16:22:54 -04:00
Edward Thomson
5ae38538c6 rebase: take checkout_options where appropriate 2015-04-20 16:22:49 -04:00
Edward Thomson
eaf0d68830 rebase: block rebase_commit with unstaged changes 2015-04-20 16:22:39 -04:00
Edward Thomson
49b3ddf216 rebase: commit should return GIT_EUNMERGED
git_rebase_commit should return `GIT_EUNMERGED` when unmerged items
exist in the index, per the documentation.  Test that this is correct.
2015-04-20 16:22:31 -04:00
Edward Thomson
30640aa9ad rebase: identify a rebase that has not started
In `git_rebase_operation_current()`, indicate when a rebase has not
started (with `GIT_REBASE_NO_OPERATION`) rather than conflating that
with the first operation being in-progress.
2015-04-20 16:22:27 -04:00
Edward Thomson
e009a7059d config_file: comment char can be invalid escape
Don't assume that comment chars are comment chars, they may be (an
attempt to be escaped).  If so, \; is not a valid escape sequence,
complain.
2015-04-20 00:26:00 -04:00
Edward Thomson
7f2e61f3ee config_file: parse multilines generously
Combine unquoting and multiline detection to avoid ambiguity when
parsing.
2015-04-20 00:25:44 -04:00
Carlos Martín Nieto
efc2fec50e push: report the update plan to the caller
It can be useful for the caller to know which update commands will be
sent to the server before the packfile is pushed up. git does this via
the pre-push hook.

We don't have hooks, but as it adds introspection into what is
happening, we can add a callback which performs the same function.
2015-04-19 01:02:29 +02:00
Edward Thomson
4c02d39374 Merge pull request #3016 from pks-t/ignore-exclude-fix
ignore: fix negative ignores without wildcards.
2015-04-17 16:57:26 -05:00
Edward Thomson
a0e652d281 Merge pull request #2999 from pks-t/submodule-set-url
Implement git_submodule_set_branch.
2015-04-17 12:35:41 -05:00
Jeff Hostetler
e3737a4185 Fix memleak in test/core/mkdir reported by CRTDBG 2015-04-17 10:30:33 -04:00
Patrick Steinhardt
4f3586034b ignore: fix negative ignores without wildcards. 2015-04-17 09:59:16 +02:00
Edward Thomson
6f80bf4afb Merge pull request #3037 from libgit2/cmn/hide-then-push
Handle hide-then-push in the revwalk
2015-04-16 19:12:28 -05:00
Edward Thomson
fa7281db4e Merge pull request #3039 from jeffhostetler/jeffhostetler/msvc_crtdbg
Add memory leak detection/reporting using MSVC CRTDBG facility.
2015-04-16 18:26:47 -05:00
Jeff Hostetler
d06c589f48 Add MSVC CRTDBG memory leak reporting. 2015-04-15 10:25:09 -04:00
Patrick Steinhardt
129788a623 Implement git_submodule_set_branch. 2015-04-12 10:51:08 +02:00
Edward Thomson
623fbd93f1 Merge pull request #2974 from libgit2/cmn/clone-everything
Make sure to pack referenced objects for non-branches
2015-04-10 11:38:07 +02:00
Edward Thomson
63af449e24 Merge pull request #3030 from linquize/symlink_supported
If work_dir is not specified, use repo_dir to test if symlink is supported
2015-04-10 11:33:14 +02:00
Patrick Steinhardt
129022ee1e Fix checking of return value for regcomp.
The regcomp function returns a non-zero value if compilation of
a regular expression fails. In most places we only check for
negative values, but positive values indicate an error, as well.
Fix this tree-wide, fixing a segmentation fault when calling
git_config_iterator_glob_new with an invalid regexp.
2015-04-10 09:40:33 +02:00
Carlos Martín Nieto
5a503fffbc revwalk: add failing test for hiding and then pushing a commit
When we hide a commit which we later push into the revwalk, we do not
handle this well and return commits which we should not.
2015-04-08 23:42:36 +02:00
Patrick Steinhardt
08e1fd6517 describe: only abort without tags if fallback is not allowed.
When no reference names could be found we did error out when trying to describe
a commit. This is wrong, though, when the option to fall back to a commit's
object ID is set.
2015-04-07 17:32:56 +02:00
John Fultz
67db2bdeea Fix git_checkout_tree() to do index filemodes correctly on Windows.
git_checkout_tree() has some fallback behaviors for file systems
which don't have full support of filemodes.  Generally works fine,
but if a given file had a change of type from a 0644 to 0755 (i.e.,
you add executable permissions), the fallback behavior incorrectly
triggers when writing hte updated index.

This would cause a git_checkout_tree() command, even with the
GIT_CHECKOUT_FORCE option set, to leave a dirty index on Windows.

Also added checks to an existing test to catch this case.
2015-04-06 18:22:17 -05:00
Linquize
7c2a2172b8 Test: Create repo in while current dir is readonly and checkout symlink 2015-04-04 23:23:19 +08:00
Edward Thomson
de355f2341 Merge pull request #3011 from ethomson/filter_zero_tempbuf
Clear temporary buffer when filtering
2015-03-25 13:14:28 -04:00
Jacques Germishuys
7c2b9e063b Illustrate bad checkout on Windows 2015-03-25 10:20:47 -04:00
Edward Thomson
78db0239db squash some leaks 2015-03-24 20:58:00 +00:00
Edward Thomson
95d1624b8d Merge pull request #2947 from libgit2/cmn/notes-buf
note: use a git_buf to return the default namespace
2015-03-24 08:34:12 -04:00
Edward Thomson
89ba9f1acc Merge pull request #2967 from jacquesg/merge-whitespace
Allow merges of files (and trees) with whitespace problems/fixes
2015-03-18 13:17:04 -04:00
Carlos Martín Nieto
7568bdf4ab Merge pull request #2993 from ethomson/clar_update
clar: update to 08f434d
2015-03-18 05:04:50 +01:00
Carlos Martín Nieto
83ad46f726 Merge remote-tracking branch 'ethomson/submodule_8dot3' 2015-03-18 04:59:16 +01:00
Edward Thomson
4c2e6b1e87 Merge pull request #2985 from claudiuolteanu/patch-1
Lower case the include directive of windows header
2015-03-17 23:35:52 -04:00
Edward Thomson
08c29c4451 clar: update to 08f434d 2015-03-17 19:04:48 -04:00
Carlos Martín Nieto
d23fb5c943 clone: add failing test for local transport with a tag
When there is a tag, we must make sure that we get all referenced
objects from this tag as well. This failing test shows that e.g. when
there is a tagged tree, we insert the top tree but do not descend, thus
causing the clone to have broken links.
2015-03-17 20:50:39 +01:00
Carlos Martín Nieto
385449b1df note: use a git_buf to return the default namespace
The caller has otherwise no way to know how long the string will be
allocated or ability to free it.

This fixes #2944.
2015-03-17 20:50:02 +01:00
Edward Thomson
9bbc8f350b Merge pull request #2962 from libgit2/cmn/reflog-annotated
Add annotated versions of ref-modying functions
2015-03-17 10:21:28 -04:00
Edward Thomson
828e595969 Merge pull request #2982 from libgit2/cmn/stream-check-ec
Don't ask for a stream's certificate unless it's encrypted
2015-03-17 09:44:56 -04:00
Edward Thomson
c07d02064d Merge pull request #2977 from pks-t/submodule-sync-url-fix
Fix git_submodule_sync writing URL to wrong key.
2015-03-17 09:44:25 -04:00
Claudiu Olteanu
118e6fdc8f Lower case the include directive of windows header
Since the Linux platform has a case sensitive file system, the header name should be lower case for cross compiling purposes. (On Linux, the mingw header is called ```windows.h```).
2015-03-16 23:08:16 +02:00
Carlos Martín Nieto
29e7ae5d81 Add failing test for cert callback with non-ecrypted stream
When we have an HTTP stream and have set the certificatre check
callback, we currently fail as we ask the unencrypted stream for its
certificate.
2015-03-16 19:39:05 +01:00
Carlos Martín Nieto
a5815a2afb Add tests for the annotated versions of ref-modifying functions
This also brings the soft-reset tests back to life. The function name
was missing an underscore, meaning they had not been running.
2015-03-16 16:57:30 +01:00
Jacques Germishuys
13de936316 Collapse whitespace flags into git_merge_file_flags_t 2015-03-16 09:53:27 +02:00
Jacques Germishuys
f29dde6828 Renamed git_merge_options 'flags' to 'tree_flags' 2015-03-16 09:53:27 +02:00
Jacques Germishuys
0f24cac2b9 Added tests to merge files and branches with whitespace problems and fixes 2015-03-16 09:53:27 +02:00
Carlos Martín Nieto
e5e2c11d5d Put back the number of expected references to 6 from the test repo
This was but down to 5 when GitHub made a change to their server which
made them stop honouring the include-tag request.

This has recently been corrected, so we can bring it back up to six.
2015-03-13 17:52:07 +01:00
Patrick Steinhardt
e6903ea278 Fix git_submodule_sync writing URL to wrong key.
Currently git_submodule_sync writes the submodule's URL to the
key 'branch.<REMOTE_NAME>.remote' while the reference
implementation of `git submodule sync` writes to
'remote.<REMOTE_NAME>.url', which is the intended behavior
according to git-submodule(1).
2015-03-12 16:05:07 +01:00
Carlos Martín Nieto
15f581747c Merge commit 'refs/pull/2879/head' of ssh://github.com/libgit2/libgit2 2015-03-11 17:55:39 +01:00
Carlos Martín Nieto
522df1cf1d Merge pull request #2970 from ethomson/inmemory_bare
"In-memory" repos are bare by default
2015-03-11 03:03:54 +01:00
Edward Thomson
70c735e190 repository_new: test its bareness 2015-03-10 16:49:24 -04:00
Pierre-Olivier Latour
b5ab878f4c Fixed build warning 2015-03-08 14:09:50 -07:00
Carlos Martín Nieto
d578b45f3f refdb: use the same id for old and new when renaming a reference
When we rename a reference, we want the old and new ids to be the same
one (as we did not change it). The normal code path looks up the old id
from the current value of the brtanch, but by the time we look it up, it
does not exist anymore and thus we write a zero id.

Pass the old id explicitly instead.
2015-03-08 16:50:27 +01:00
Edward Thomson
01c3b184d3 Merge pull request #2961 from ethomson/filter_relative_paths
Filter relative paths
2015-03-06 16:52:07 -05:00
Edward Thomson
0b3dd8fbed filter::file tests: test filter_list_apply_to_file
Test that filter_list_apply_to_file works and can accept repo-relative
paths.
2015-03-06 15:16:05 -05:00
nulltoken
7eb7673406 branch: fix generated reflog message upon renaming 2015-03-04 22:09:49 +01:00
nulltoken
015d4b7b38 branch: fix generated reflog message upon creation 2015-03-04 22:09:44 +01:00
Carlos Martín Nieto
bdf0e73450 Merge pull request #2932 from jeffhostetler/jeffhostetler/big_clone_crash
Fix crash in git_clone on extremely large repos
2015-03-04 14:55:56 +01:00
Edward Thomson
83fe60fa1b libgit2_shutdown: clear err message on shutdown
Clear the error message on git_libgit2_shutdown for all versions of
the library (no threads and Win32 threads).  Drop the giterr_clear
in clar, as that shouldn't be necessary.
2015-03-04 14:48:46 +01:00
Carlos Martín Nieto
814d86bfe3 Merge pull request #2886 from jeffhostetler/jeffhostetler/clar_trace
Set up git_trace in clar test suite.
2015-03-04 14:32:23 +01:00
Carlos Martín Nieto
c69c042e0e Merge pull request #2945 from ethomson/empty_hashsig_heap
diff_tform: don't compare empty hashsig_heaps
2015-03-04 12:47:59 +01:00
Edward Thomson
f78d9b6cfe diff_tform: account for whitespace options
When comparing seemingly blank files, take whitespace options into
account.
2015-03-04 00:01:34 -05:00
Carlos Martín Nieto
fe21d708b0 Plug a few leaks 2015-03-04 00:29:37 +01:00
Edward Thomson
a212716fc3 diff_tform: don't compare empty hashsig_heaps
Don't try to compare two empty hashsig_heaps.
2015-03-03 18:19:42 -05:00
Carlos Martín Nieto
9a97f49e3a config: borrow refcounted references
This changes the get_entry() method to return a refcounted version of
the config entry, which you have to free when you're done.

This allows us to avoid freeing the memory in which the entry is stored
on a refresh, which may happen at any time for a live config.

For this reason, get_string() has been forbidden on live configs and a
new function get_string_buf() has been added, which stores the string in
a git_buf which the user then owns.

The functions which parse the string value takea advantage of the
borrowing to parse safely and then release the entry.
2015-03-03 18:35:12 +01:00
Carlos Martín Nieto
76f034180a Remove swp files 2015-03-03 17:04:38 +01:00
Edward Thomson
018fdbb580 Merge pull request #2913 from ethomson/stash_fixup
stash: correctly stash wd modified/index deleted
2015-03-03 10:08:28 -05:00
Jeff Hostetler
e5cf1c704c Converted cl_perf_timer to use git__timer internally. 2015-03-03 09:57:50 -05:00
Jeff Hostetler
7e9b21aa2a Fix p_ftruncate to handle big files for git_clone 2015-03-03 08:47:44 -05:00
Carlos Martín Nieto
4e498646b6 repository: remove log message override for switching the active branch
We want to use the "checkout: moving from ..." message in order to let
git know when a change of branch has happened. Make the convenience
functions for this goal write this message.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
412a380888 push: remove reflog message override
We always use "update by push".
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
6bfb990dc7 branch: don't accept a reflog message override
This namespace is about behaving like git's branch command, so let's do
exactly that instead of taking a reflog message.

This override is still available via the reference namespace.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
23a17803b6 reset: remove reflog message override
This function is meant to simulate what git does in the reset command,
so we should include the reflog message in that.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
659cf2029f Remove the signature from ref-modifying functions
The signature for the reflog is not something which changes
dynamically. Almost all uses will be NULL, since we want for the
repository's default identity to be used, making it noise.

In order to allow for changing the identity, we instead provide
git_repository_set_ident() and git_repository_ident() which allow a user
to override the choice of signature.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
99b68a2aec Merge pull request #2908 from ethomson/safe_create
Allow checkout to handle newly cloned repositories, remove `GIT_CHECKOUT_SAFE_CREATE`
2015-03-03 13:47:13 +01:00
Jeff Hostetler
9a859ef55a Added cl_perf_timer. Updated global trace to include timers. 2015-03-02 09:21:55 -05:00
Jeff Hostetler
f096fbf4d6 Cleanup formatting of clar trace messages. 2015-03-02 08:34:02 -05:00
Jeff Hostetler
6b5c0886b6 Provide mechanism to let CLAR globally setup git_trace() 2015-03-02 08:20:27 -05:00
Edward Thomson
496b76d415 checkout tests: just use SAFE where appropriate 2015-02-27 13:50:48 -05:00
Edward Thomson
96b82b11c6 checkout: remove GIT_CHECKOUT_SAFE_CREATE as a strategy 2015-02-27 13:50:44 -05:00
Edward Thomson
6c9e86adaf clone: drop now unnecessary SAFE_CREATE 2015-02-27 13:50:36 -05:00
Edward Thomson
e6da3e4496 checkout: upgrade to SAFE_CREATE when no index file
When the repository does not contain an index, emulate git's behavior
and upgrade to `SAFE_CREATE`.  This allows us to check out repositories
created with `git clone --no-checkout`.
2015-02-27 13:50:32 -05:00
Edward Thomson
5cbe950fb8 merge perf test: drop unnecessary SAFE_CREATE 2015-02-27 13:47:34 -05:00
Edward Thomson
cfcb346d94 Update to clar 2b73f5e 2015-02-27 00:30:50 -05:00
Edward Thomson
4196dd8e8f repository: Introduce "reserved names"
A repository can have multiple "reserved names" now, not just
a single "short name" for the repository folder itself.  Refactor
to include a git_repository__reserved_names that returns all the
reserved names for a repository.
2015-02-27 04:36:47 +00:00
Damien PROFETA
a275fbc0f7 Add API to add a memory buffer to an index
git_index_add_frombuffer enables now to store a memory buffer in the odb
and to store an entry in the index directly if the index is attached to a
repository.
2015-02-25 10:24:13 +01:00
Edward Thomson
feb0e02286 tests: separate INVASIVE filesystem tests
Introduce GITTEST_INVASIVE_FS_STRUCTURE for things that are invasive
to your filesystem structure (like creating folders at your filesystem
root) and GITTEST_INVASIVE_FS_SIZE for things that write lots of data.
2015-02-19 12:14:06 -05:00
Edward Thomson
795eaccd66 git_filter_opt_t -> git_filter_flag_t
For consistency with the rest of the library, where an opt is an
options *structure*.
2015-02-19 11:09:54 -05:00
Edward Thomson
09866d6f84 stash: correctly stash wd modified/index deleted 2015-02-18 11:26:03 -05:00
Edward Thomson
f7c0125f47 filter streams: base -> parent 2015-02-18 10:24:34 -05:00
Edward Thomson
b75f15aaf1 git_writestream: from git_filter_stream 2015-02-18 10:24:23 -05:00
Edward Thomson
8c2dfb38db filter: test a large file through the stream
Test pushing a file on-disk into a streaming filter that compresses
it into the ODB, and inflates it back into the working directory.
2015-02-17 17:00:57 -05:00
Stefan Widgren
c8e02b8776 Remove extra semicolon outside of a function
Without this change, compiling with gcc and pedantic generates warning:
ISO C does not allow extra ‘;’ outside of a function.
2015-02-15 21:07:05 +01:00
Carlos Martín Nieto
a291790a8d Merge pull request #2831 from ethomson/merge_lock
merge: lock index during the merge (not just checkout)
2015-02-15 05:18:01 +01:00
Carlos Martín Nieto
a7fa970f8b Merge pull request #2895 from ethomson/alloc_overflow
allocations: test for overflow of requested size
2015-02-15 05:13:50 +01:00
Edward Thomson
8b0ddd5dd9 merge: lock the index at the start of the merge
Always lock the index when we begin the merge, before we write
any of the metdata files.  This prevents a race where another
client may run a commit after we have written the MERGE_HEAD but
before we have updated the index, which will produce a merge
commit that is treesame to one parent.  The merge will finish and
update the index and the resultant commit would not be a merge at
all.
2015-02-14 09:25:35 -05:00
Edward Thomson
8639ea5f98 checkout: introduce GIT_CHECKOUT_DONT_WRITE_INDEX 2015-02-14 09:25:35 -05:00
Edward Thomson
55798fd153 git_indexwriter: lock then write the index
Introduce `git_indexwriter`, to allow us to lock the index while
performing additional operations, then complete the write (or abort,
unlocking the index).
2015-02-14 09:25:35 -05:00
Edward Thomson
42f98a26a5 merge test: test an actual failure, not conflict
Correct the merge failed cleanup test.  Merge data should not be
cleaned up on conflicts, only on actual failure.  And ORIG_HEAD
should not be removed at all.
2015-02-13 11:44:34 -05:00
Edward Thomson
49b8293c75 rebase: allow NULL branch to indicate HEAD
Don't require the branch to rebase, if given `NULL`, simply look up
`HEAD`.
2015-02-13 11:20:32 -05:00
Edward Thomson
92e87dd749 rebase: provide NULL exec on non-EXEC operations
Users may want to try to pay attention to the `exec` field on all
rebase operations.
2015-02-13 10:44:19 -05:00
Edward Thomson
d97d9559e3 buf test: cleanup memory leak 2015-02-13 09:28:12 -05:00
Edward Thomson
f1453c59b2 Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it.  This means dropping the ability to pass `NULL` as
an out parameter.

As a result, the macros also get updated to reflect this as well.
2015-02-13 09:27:33 -05:00
Carlos Martín Nieto
0b2ee7c07c Merge pull request #2883 from urkud/reget-reader-pointer
Reinit `reader` pointer after reading included config file
2015-02-13 08:56:01 +01:00
Edward Thomson
2884cc42de overflow checking: don't make callers set oom
Have the ALLOC_OVERFLOW testing macros also simply set_oom in the
case where a computation would overflow, so that callers don't
need to.
2015-02-12 22:54:47 -05:00
Edward Thomson
4aa664ae39 git_buf_grow_by: increase buf asize incrementally
Introduce `git_buf_grow_by` to incrementally increase the size of a
`git_buf`, performing an overflow calculation on the growth.
2015-02-12 22:54:47 -05:00
Edward Thomson
392702ee2c allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic
and set error message appropriately.
2015-02-12 22:54:46 -05:00
Yury G. Kudryashov
3ea78f241f Add test for include.path inside included config
It fails at least on my computer, though it may depend on some unpredictable
factors (say, will realloc() extend the memory segment in place, or it will
allocate new memory).
2015-02-13 00:15:16 +03:00
Carlos Martín Nieto
d24a5312d8 Merge pull request #2866 from ethomson/checkout_perf2
Checkout performance
2015-02-12 02:34:58 +01:00
Carlos Martín Nieto
8e29ae7310 Merge pull request #2862 from jeffhostetler/jeffhostetler/bug/branch_create_after_namespace
Remove stale reflog namespace directory before branch creation
2015-02-12 00:43:01 +01:00
Carlos Martín Nieto
e07c1e1a15 Merge pull request #2880 from ethomson/mkdir_root
Ensure we can make a repo at the root of the filesystem
2015-02-12 00:40:12 +01:00
Carlos Martín Nieto
6dbbced2b1 Merge pull request #2889 from jeffhostetler/jeffhostetler/merge_performance
Large merge perf test.
2015-02-12 00:27:17 +01:00
Jeff Hostetler
d97ba7f674 Large merge perf test. 2015-02-06 15:45:59 -05:00
Edward Thomson
83276dccbe Update clar to d17c7f6 2015-02-05 13:24:38 -05:00
Edward Thomson
3c68bfcd08 stat: don't remove trailing '/' from root on win32
`p_stat` calls `git_win32_path_from_utf8`, which canonicalizes the
path.  Do not further try to modify the path, else we trim the
trailing slash from a root directory and try to access `C:` instead
of `C:/`.
2015-02-05 12:27:16 -05:00
Edward Thomson
865baaf928 repo: ensure we can create repo at filesystem root
Test to ensure that we can create a repository at the filesystem
root.  Introduces a new test environment variable,
`GITTEST_INVASIVE_FILESYSTEM` for tests that do terrible things like
escaping the clar sandbox and writing to the root directory.  It is
expected that the CI builds will enable this but that normal people
would not want this.
2015-02-05 11:59:03 -05:00
Edward Thomson
9bf5bd7cd8 Merge pull request #2867 from ethomson/8dot3
Handle 8dot3 filenames being disabled on Win32
2015-02-05 09:19:46 -05:00
Edward Thomson
fa89ff20cd remove some unused warnings 2015-02-04 14:15:13 +00:00
Edward Thomson
f45f9b6dbc structinit test: use %PRIuZ instead of %d for size_t 2015-02-04 03:52:34 +00:00
Edward Thomson
07c989e98d win32: further cleanups for 8.3 disabling 2015-02-03 20:01:24 -05:00
Edward Thomson
5f28ec84a1 win32: cleanup 8.3 disabled tests 2015-02-03 12:23:04 -05:00
Jeff Hostetler
1589a93aa6 Fix branch creation when branch name matches namespace of previously deleted branch 2015-02-03 10:33:04 -05:00
Edward Thomson
60561d5446 tests: update for new test data 2015-02-02 22:46:43 -05:00
Edward Thomson
2fbce0bfac checkout test: ensure .gitattributes lifecycle
The .gitattributes cache should not reload .gitattributes in the
middle of checking out, only between checkout operations.  Otherwise,
we'll spend all our time stat'ing and read'ing the gitattributes.
2015-02-02 22:46:39 -05:00
Edward Thomson
f83c19c87d Merge pull request #2832 from ethomson/appveyor_badge
64-bit Appveyor Builds
2015-01-30 14:16:45 -05:00
Linquize
9dcc4a36f7 Fix test failures when 8.3 is disabled 2015-01-31 00:09:31 +08:00
Edward Thomson
1ac5acdc69 Merge pull request #2819 from libgit2/cmn/config-get-path
config: add parsing and getter for paths
2015-01-26 11:28:59 -06:00
Edward Thomson
7c48508b28 structinit test: only run on DEBUG builds
The structinit tests don't make sense unless structure padding
is uniformly initialized, which is unlikely to happen on release
builds.  Only enable them for DEBUG builds.  Further, rename them
to core::structinit.
2015-01-21 12:55:17 -06:00
Edward Thomson
0ad5c845d2 structinit test: show which byte differs 2015-01-21 11:53:20 -06:00
Edward Thomson
e0902fbce7 checkout tests: cleanup realpath impl on Win32 2015-01-20 17:13:52 -06:00
Edward Thomson
53eb139dcb checkout tests: emulate p_realpath poorly on Win32 2015-01-20 17:13:41 -06:00
Edward Thomson
e74340b000 checkout: remove files before writing new ones
On case insensitive filesystems, we may have files in the working
directory that case fold to a name we want to write.  Remove those
files (by default) so that we will not end up with a filename that
has the unexpected case.
2015-01-20 17:13:31 -06:00
Edward Thomson
232bc89598 checkout tests: nasty symlinks
Symbolic links that abuse case insensitivity to write into .git.
2015-01-20 17:13:09 -06:00
Edward Thomson
1fbfcdfcd0 git_path_join_unrooted: return base len
The documentation for `git_path_join_unrooted` states that the base
length will be returned, so that consumers like checkout know where
to start creating directories instead of always creating directories
at the directory root.
2015-01-20 17:12:35 -06:00
Edward Thomson
1d50b3649d checkout: introduce git_checkout_perfdata
Checkout can now provide performance data about the number of (some)
syscalls performed using an optional callback.
2015-01-20 17:12:23 -06:00
Linquize
b4c6a9da93 Add files and tests with many UTF-8 chars and few UTF-8 chars 2015-01-20 16:17:48 -06:00
Sven Strickroth
0161e096a3 Make binary detection work similar to vanilla git
Main change: Don't treat chars > 128 as non-printable (common in UTF-8 files)

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2015-01-20 16:17:37 -06:00
Carlos Martín Nieto
eac773d92b config: add parsing and getter for paths 2015-01-14 19:36:50 +01:00
Edward Thomson
85880693d5 Merge branch 'pr/2740' 2015-01-14 10:19:28 -06:00
Pierre-Olivier Latour
36fc549781 Added GIT_HASHSIG_ALLOW_SMALL_FILES to allow computing signatures for small files
The implementation of the hashsig API disallows computing a signature on
small files containing only a few lines. This new flag disables this
behavior.

git_diff_find_similar() sets this flag by default which means that rename
/ copy detection of small files will now work. This in turn affects the
behavior of the git_status and git_blame APIs which will now detect rename
of small files assuming the right options are passed.
2015-01-14 10:17:56 -06:00
Carlos Martín Nieto
d4b2410126 Merge commit '4b1018d24f980273528743c27c47ceb96cb720bd'
Fix crash in free() when git_buf_grow() fails.
2015-01-09 16:47:48 +01:00
Jeff Hostetler
4b1018d24f Fix crash in free() when git_buf_grow() fails. 2015-01-09 16:46:44 +01:00
Carlos Martín Nieto
fe8399fe9b Fix warning 2015-01-09 16:29:08 +01:00
Carlos Martín Nieto
788c5f1ca8 Merge pull request #2810 from ethomson/remove_symlinks
Remove symlinks from the repository
2015-01-09 10:23:08 +01:00
Edward Thomson
365d367238 submodule::init tests: free some leaks 2015-01-08 22:31:15 +00:00
Edward Thomson
3b40ed897f repo::init test: create hook symlink
Remove the hook symlink from the test resources, so that we can
have a source tree that is easy to zip up and copy around on systems
that don't support symlinks.  Create it dynamically at test execution
instead.
2015-01-08 19:23:37 +00:00
Edward Thomson
1646412d8f Merge pull request #2802 from calavera/remote_create_prune_config
Load prune configuration when a remote is created.
2015-01-08 11:20:44 -06:00
David Calavera
de4a75f977 Fix more indentation. 2015-01-07 09:26:36 -08:00
David Calavera
c868981f0e Add extern function to initialize submodule update options. 2015-01-07 09:04:49 -06:00
David Calavera
66b71ea5f5 Fix intentation. 2015-01-05 13:33:36 -08:00
David Calavera
1ef3f0cebb Load prune configuration when a remote is created. 2015-01-05 13:24:11 -08:00
Carlos Martín Nieto
0c6012293a Merge commit 'refs/pull/2632/head' of github.com:libgit2/libgit2 2015-01-05 20:10:43 +00:00
Carlos Martín Nieto
c4a2fd5c1d Plug a couple of leaks 2015-01-04 17:39:43 +00:00
Edward Thomson
a3ef70bb40 Merge pull request #2761 from libgit2/cmn/fetch-prune
Remote-tracking branch prunning
2014-12-30 11:53:55 -06:00
Edward Thomson
c4c47fc286 Merge pull request #2762 from libgit2/cmn/hide-push
remote: remove git_push from the public API
2014-12-30 11:53:45 -06:00
Carlos Martín Nieto
fe794b2ea7 remote: remove git_push from the public API
Instead we provide git_remote_upload() and git_remote_update_tips() in
order to have a parallel API for fetching and pushing.
2014-12-30 17:02:50 +00:00
Carlos Martín Nieto
208a2c8aef treebuilder: rename _create() to _new()
This function is a constructor, so let's name it like one and leave
_create() for the reference functions, which do create/write the
reference.
2014-12-27 12:09:11 +00:00
Edward Thomson
40d791545a Always checkout with case sensitive iterator
On a case-insensitive filesystem, we need to deal with case-changing
renames (eg, foo -> FOO) by removing the old and adding the new,
exactly as if we were on a case-sensitive filesystem.

Update the `checkout::tree::can_cancel_checkout_from_notify` test, now
that notifications are always sent case sensitively.
2014-12-23 10:14:04 -06:00
Edward Thomson
61ee5b0e57 Introduce test for checkout case-changing rename 2014-12-23 10:14:01 -06:00
Jameson Miller
9d1f97df10 Introduce a convenience function for submodule update
This introduces the functionality of submodule update in
'git_submodule_do_update'. The existing 'git_submodule_update' function is
renamed to 'git_submodule_update_strategy'. The 'git_submodule_update'
function now refers to functionality similar to `git submodule update`,
while `git_submodule_update_strategy` is used to get the configured value
of submodule.<name>.update.
2014-12-22 16:37:35 -05:00
Jameson Miller
b2ab887e11 submodule init should resolve relative url paths
Submodule init should handle relative paths in .gitmodules files
and resolve these urls when updating the git config file.
2014-12-22 16:35:45 -05:00
Edward Thomson
c7d9839f54 Merge pull request #2763 from libgit2/cmn/local-proto-progress
Show progress output on fetch for the local transport
2014-12-20 21:22:30 -06:00
Linquize
6987a580f7 Add more Windows reserved filenames 2014-12-19 23:54:42 +08:00
Linquize
6fd00266a8 COM0 is a valid path, although Windows Explorer does not allow to create this 2014-12-19 23:54:01 +08:00
Edward Thomson
2842831800 index tests: test capitalization before mkdir 2014-12-18 12:41:59 -06:00
Carlos Martín Nieto
c90ed5b558 Plug leaks 2014-12-18 02:11:06 +01:00
Carlos Martín Nieto
c679bf42f5 Create miscapitialised dirs for case-sensitive filesystems
We need these directories to exist so cl_git_mkfile() can create the
files we ask it to.
2014-12-18 02:07:36 +01:00
Edward Thomson
dce7b1a4e7 treebuilder: take a repository for path validation
Path validation may be influenced by `core.protectHFS` and
`core.protectNTFS` configuration settings, thus treebuilders
can take a repository to influence their configuration.
2014-12-17 13:05:27 -05:00
Edward Thomson
ec74b40cee Introduce core.protectHFS and core.protectNTFS
Validate HFS ignored char ".git" paths when `core.protectHFS` is
specified.  Validate NTFS invalid ".git" paths when `core.protectNTFS`
is specified.
2014-12-17 12:52:07 -05:00
Edward Thomson
11d67b754d checkout: disallow bad paths on HFS
HFS filesystems ignore some characters like U+200C.  When these
characters are included in a path, they will be ignored for the
purposes of comparison with other paths.  Thus, if you have a ".git"
folder, a folder of ".git<U+200C>" will also match.  Protect our
".git" folder by ensuring that ".git<U+200C>" and friends do not match it.
2014-12-16 10:08:59 -06:00
Edward Thomson
ee5da720e5 reference_create: validate loose names
Validate loose reference names on Win32.
2014-12-16 10:08:56 -06:00
Edward Thomson
a64119e396 checkout: disallow bad paths on win32
Disallow:
 1. paths with trailing dot
 2. paths with trailing space
 3. paths with trailing colon
 4. paths that are 8.3 short names of .git folders ("GIT~1")
 5. paths that are reserved path names (COM1, LPT1, etc).
 6. paths with reserved DOS characters (colons, asterisks, etc)

These paths would (without \\?\ syntax) be elided to other paths - for
example, ".git." would be written as ".git".  As a result, writing these
paths literally (using \\?\ syntax) makes them hard to operate with from
the shell, Windows Explorer or other tools.  Disallow these.
2014-12-16 10:08:53 -06:00
Vicent Marti
0d388adc86 index: Check for valid paths before creating an index entry 2014-12-16 10:08:49 -06:00
Edward Thomson
cceae9a25d win32: use NT-prefixed "\\?\" paths
When turning UTF-8 paths into UCS-2 paths for Windows, always use
the \\?\-prefixed paths.  Because this bypasses the system's
path canonicalization, handle the canonicalization functions ourselves.

We must:
 1. always use a backslash as a directory separator
 2. only use a single backslash between directories
 3. not rely on the system to translate "." and ".." in paths
 4. remove trailing backslashes, except at the drive root (C:\)
2014-12-16 10:08:43 -06:00
Carlos Martín Nieto
3ded7f28c7 local: add failing test for sideband information
We do not currently generate any messages when we're counting the
objects, as might be expected from a local upload-pack. Assert that we
do call the function when working.
2014-12-16 10:05:49 +01:00
Carlos Martín Nieto
4adc64a81a fetch: plug leaks in the prune tests 2014-12-14 21:52:27 +01:00
Carlos Martín Nieto
26186b155b fetch: remove the prune setter
This option does not get persisted to disk, which makes it different
from the rest of the setters. Remove it until we go all the way.

We still respect the configuration option, and it's still possible to
perform a one-time prune by calling the function.
2014-12-14 21:52:27 +01:00
Carlos Martín Nieto
7b6e1e4cc6 fetch: add test for the other order of overlapping specs 2014-12-14 21:25:08 +01:00
Carlos Martín Nieto
4aa2336966 fetch: assert we don't call update tips when there are no upates
This is hiding a bug in the prune code, whereby we prune references we
shouldn't but don't notice it in the code afterwards because
update_tips() recreates them.

This means that we do perform changes to the references (and get rid of
the reflogs) when we shouldn't.
2014-12-14 17:04:02 +01:00
Carlos Martín Nieto
020aab9308 fetch: do set prune when testing
We load the remote again, so we need to ask the new remote to prune the
refs, or we're not exercising the code in our tests.
2014-12-14 17:04:02 +01:00
David Calavera
5e0c3d2d1a Make sure that fetch --prune --tags doesn't remove tags. 2014-12-14 17:04:02 +01:00
David Calavera
b91194e842 Cleanup repository after prune tests. 2014-12-14 17:04:02 +01:00
David Calavera
93d968fa07 Cleanup after testing remote prune. 2014-12-14 17:04:02 +01:00
David Calavera
82eeba8142 Fix references to git_remote_lookup. 2014-12-14 17:04:01 +01:00
David Calavera
439e19f632 Test that prune overlapping works as expected. 2014-12-14 17:04:01 +01:00
David Calavera
ce4b57c6bc Fix calls to git_remote_download and git_remote_fetch. 2014-12-14 17:04:01 +01:00
Linquize
b8fefcb9ca Add test for prune refs 2014-12-14 17:04:01 +01:00
Edward Thomson
09debe1213 clar: wide character comparisons 2014-12-10 18:11:50 -05:00
Edward Thomson
3410084675 tests: use p_ instead of posix func directly 2014-12-10 18:11:50 -05:00
Carlos Martín Nieto
d524b2d3d1 push: fold unpack_ok() into finish()
The push cannot be successful if we sent a bad packfile. We should
return an error in that case instead of storing it elsewhere.
2014-12-10 18:55:54 +01:00
Edward Thomson
6b11eb51ee core::link test: clean up junction point name 2014-12-09 12:04:53 -05:00
Edward Thomson
80b01c8f26 win32: remember to free wide env name/value 2014-12-09 12:04:50 -05:00
Edward Thomson
d5087689b5 Merge pull request #2750 from linquize/generate.py
Update clar to e3985dd
2014-12-08 23:03:30 -05:00
Linquize
8e0aa2ebce Fix broken merge tests due to autocrlf was not false 2014-12-07 23:41:30 +08:00
Linquize
d226fbf1aa Fix broken test suite on Windows 2014-12-07 22:42:06 +08:00
Linquize
3a1eb9e5ff Update clar to e3985dd 2014-12-07 22:09:00 +08:00
Edward Thomson
19ae843937 Merge pull request #2746 from libgit2/cmn/neg-ignore-dir
Fix negative ignores withing ignored dirs
2014-12-06 20:17:16 -05:00