Commit Graph

10496 Commits

Author SHA1 Message Date
Patrick Steinhardt
f3c3068670 tests: worktree: use joinpath instead of printf to join paths 2017-03-15 17:16:47 +01:00
Edward Thomson
6dfb983cfc Merge pull request #4161 from pks-t/pks/submodule-index-fix
submodule: catch when submodule is not staged on update
2017-03-15 15:03:45 +00:00
Patrick Steinhardt
fdb3e24ac4 tests: worktree: unify init/cleanup in open tests 2017-03-15 14:24:45 +01:00
Patrick Steinhardt
548e5bdf1e tests: worktree: unify init/cleanup in submodule tests 2017-03-15 12:28:05 +01:00
Patrick Steinhardt
aa593a65df tests: worktree: move submodule tests into own suite 2017-03-15 12:01:02 +01:00
Patrick Steinhardt
bb342159d8 merge_driver: fix const-correctness for source getters 2017-03-15 11:46:15 +01:00
Patrick Steinhardt
8051b47f5b Merge branch 'gumenikav/merge_driver_source_info' 2017-03-15 08:20:26 +01:00
Gumenik Alexandr
0608d5df59 merge_driver: add unresolved getters for git_merge_driver_source 2017-03-15 08:19:48 +01:00
Patrick Steinhardt
13bf4d7f13 Merge pull request #4146 from pks-t/pks/winhttp-errors
winhttp: disambiguate error messages when sending requests
2017-03-14 15:04:18 +01:00
Patrick Steinhardt
32ecc98e51 submodule: catch when submodule is not staged on update
When calling `git_submodule_update` on a submodule, we have to retrieve
the ID of the submodule entry in the index. If the function is called on
a submodule which is only partly initialized, the submodule entry may
not be added to the index yet. This leads to an assert when trying to
look up the blob later on.

Fix the issue by checking if the index actually holds the submodule's
ID and erroring out if it does not.
2017-03-14 14:53:32 +01:00
Patrick Steinhardt
c0eba379d1 diff_parse: correctly set options for parsed diffs
The function `diff_parsed_alloc` allocates and initializes a
`git_diff_parsed` structure. This structure also contains diff options.
While we initialize its flags, we fail to do a real initialization of
its values. This bites us when we want to actually use the generated
diff as we do not se the option's version field, which is required to
operate correctly.

Fix the issue by executing `git_diff_init_options` on the embedded
struct.
2017-03-14 13:09:35 +01:00
Patrick Steinhardt
ad5a909cfb patch_parse: fix parsing minimal trailing diff line
In a diff, the shortest possible hunk with a modification (that is, no
deletion) results from a file with only one line with a single character
which is removed. Thus the following hunk

    @@ -1 +1 @@
    -a
    +

is the shortest valid hunk modifying a line. The function parsing the
hunk body though assumes that there must always be at least 4 bytes
present to make up a valid hunk, which is obviously wrong in this case.
The absolute minimum number of bytes required for a modification is
actually 2 bytes, that is the "+" and the following newline. Note: if
there is no trailing newline, the assumption will not be offended as the
diff will have a line "\ No trailing newline" at its end.

This patch fixes the issue by lowering the amount of bytes required.
2017-03-14 13:09:13 +01:00
Patrick Steinhardt
62a2fc06d4 patch_generate: move git_diff_foreach to diff.c
Now that the `git_diff_foreach` function does not depend on internals of
the `git_patch_generated` structure anymore, we can easily move it to
the actual diff code.
2017-03-14 13:08:51 +01:00
Patrick Steinhardt
ace3508f4c patch_generate: fix git_diff_foreach only working with generated diffs
The current logic of `git_diff_foreach` makes the assumption that all
diffs passed in are actually derived from generated diffs. With these
assumptions we try to derive the actual diff by inspecting either the
working directory files or blobs of a repository. This obviously cannot
work for diffs parsed from a file, where we do not necessarily have a
repository at hand.

Since the introduced split of parsed and generated patches, there are
multiple functions which help us to handle patches generically, being
indifferent from where they stem from. Use these functions and remove
the old logic specific to generated patches. This allows re-using the
same code for invoking the callbacks on the deltas.
2017-03-14 13:08:28 +01:00
Patrick Steinhardt
41019152a0 patch_generate: remove duplicated logic
Under the existing logic, we try to load patch contents differently,
depending on whether the patch files stem from the working directory or
not. But actually, the executed code paths are completely equal to each
other -- so we were always the code despite the condition.

Remove the condition altogether and conflate both code paths.
2017-03-14 12:04:04 +01:00
Carlos Martín Nieto
53454be87f Merge pull request #4157 from adamniedzielski/4099-git-sort-time-uninteresting
Skip uninteresting commits in revwalk timesort iterator
2017-03-11 19:52:05 +01:00
Carlos Martín Nieto
0b3623ac47 Merge pull request #4156 from libgit2/ethomson/readbuffer_dont_hash
git_futils_readbuffer: don't compute sha-1
2017-03-11 19:09:27 +01:00
Edward Thomson
ffd4df6bf2 Merge pull request #4151 from novalis/dturner/rebase-submodule-untracked
rebase: ignore untracked files in submodules
2017-03-09 16:32:38 +00:00
Adam Niedzielski
c11c08a552 Skip uninteresting commits in revwalk timesort iterator
Fixes #4099
2017-03-09 14:01:10 +01:00
Edward Thomson
11c8e756ac git_futils_readbuffer: don't compute sha-1
Don't compute the sha-1 in `git_futils_readbuffer_updated` unless the
checksum was requested.  This means that `git_futils_readbuffer` will
not calculate the checksum unnecessarily.
2017-03-09 12:26:23 +00:00
Edward Thomson
b31b236004 Merge pull request #4154 from libgit2/ethomson/namespaces
Support namespaced references again
2017-03-06 15:53:57 +00:00
Edward Thomson
835805625a refdb_fs: honor the namespace 2017-03-06 14:20:12 +00:00
Edward Thomson
d24ae06d72 refs::namespace: add namespace tests
These simple tests only ensure that we enforce the existence of a
namespace; these mirror the rugged tests, they are not exhaustive.
2017-03-06 14:11:00 +00:00
Richard Ipsum
5c06111be6 README: Mention how to run tests 2017-03-05 15:36:19 +00:00
David Turner
2270ca9f8f rebase: ignore untracked files in submodules
An untracked file in a submodule should not prevent a rebase from
starting.  Even if the submodule's SHA is changed, and that file would
conflict with a new tracked file, it's still OK to start the rebase
and discover the conflict later.

Signed-off-by: David Turner <dturner@twosigma.com>
2017-03-03 15:07:54 -05:00
Carlos Martín Nieto
467185ff13 Merge pull request #4150 from libgit2/ethomson/freshen_trees
git_commit_create: freshen tree objects in commit
2017-03-03 16:12:12 +01:00
Edward Thomson
52d03f37f7 git_commit_create: freshen tree objects in commit
Freshen the tree object that a commit points to during commit time.
2017-03-03 14:12:00 +00:00
Carlos Martín Nieto
3348570a0c Merge pull request #4136 from libgit2/ethomson/sha1dc
Introduce (optional) SHA1 collision attack detection
2017-03-03 12:36:36 +01:00
Edward Thomson
9f128d2a77 cmake: drop unset SHA1_TYPE
We never set `SHA1_TYPE` to `builtin`.  Don't bother testing for it.
2017-03-03 10:50:28 +00:00
Edward Thomson
d087c8f80e hash: test for sha1 collision attack detection 2017-03-03 10:50:28 +00:00
Edward Thomson
2dfd1294f7 hash: include sha1collisiondetection
Include the SHA1 collision attack detection library from
https://github.com/cr-marcstevens/sha1collisiondetection
2017-03-03 10:50:27 +00:00
Edward Thomson
a371a8ae94 hash: rename implementation selection constants 2017-03-03 10:50:27 +00:00
Edward Thomson
1c04a96b25 Honor core.fsyncObjectFiles 2017-03-02 09:11:33 +00:00
Patrick Steinhardt
ba2bc4911d Merge pull request #4148 from pks-t/pks/fix-haiku-builds
cmake: only enable supported compiler warning flags
2017-03-01 14:51:39 +01:00
Patrick Steinhardt
a02e8a3882 cmake: only enable supported compiler warning flags
We currently unconditionally enable the "-Wall" and "-Wextra" flags.
Some platforms rely on compilers which do not support these flags,
though. One of these platforms is Haiku, which does not support
"-Wextra" due to being stuck on GCC version 2.

Fix builds on such platforms by adding these flags only if supported by
the compiler.
2017-03-01 13:58:15 +01:00
Patrick Steinhardt
a454641ee8 Merge pull request #4145 from pks-t/pks/refs-create-memleak
tests: refs::create: fix memory leak
2017-03-01 08:45:48 +01:00
Patrick Steinhardt
b65a5e9ba9 winhttp: disambiguate error messages when sending requests 2017-03-01 07:58:40 +01:00
Patrick Steinhardt
5aa1f12a81 tests: refs::create: fix memory leak 2017-03-01 07:45:14 +01:00
Patrick Steinhardt
cf8e9a3ad5 Merge pull request #4143 from richardipsum/issue-4094
Fix: make reflog include "(merge)" for merge commits
2017-03-01 07:35:44 +01:00
Richard Ipsum
397cf1a1f5 Add test for inclusion of (merge) in reflog
This test ensures that the string '(merge)' is included in the reflog
when a merge commit is made.
2017-02-28 22:32:21 +00:00
Edward Thomson
3ac05d1149 win32: don't fsync parent directories on Windows
Windows doesn't support it.
2017-02-28 13:29:01 +00:00
Edward Thomson
2a5ad7d0f2 fsync: call it "synchronous" object writing
Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` ->
`GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
2017-02-28 13:29:01 +00:00
Edward Thomson
1229e1c4d7 fsync parent directories when fsyncing
When fsync'ing files, fsync the parent directory in the case where we
rename a file into place, or create a new file, to ensure that the
directory entry is flushed correctly.
2017-02-28 13:28:36 +00:00
Edward Thomson
5a747e0c6c git_futils_writebuffer: default only when flags==0
Only use defaults for `git_futils_writebuffer` when flags == 0, lest
(1 << 31) be treated as the defaults.
2017-02-28 13:28:36 +00:00
Edward Thomson
eb56ed81af refdb_fs: optionally fsync packed refs 2017-02-28 13:28:36 +00:00
Edward Thomson
af3dcb0e50 refdb_fs: optionally fsync loose references 2017-02-28 13:28:36 +00:00
Edward Thomson
5312621bd4 git_futils_writebuffer: optionally fsync
Add a custom `O_FSYNC` bit (if it's not been defined by the operating
system`) so that `git_futils_writebuffer` can optionally do an `fsync`
when it's done writing.

We call `fsync` ourselves, even on systems that define `O_FSYNC` because
its definition is no guarantee of its actual support.  Mac, for
instance, defines it but doesn't support it in an `open(2)` call.
2017-02-28 13:27:50 +00:00
Edward Thomson
1c2c0ae2a4 packbuilder: honor git_object__synchronized_writing
Honor `git_object__synchronized_writing` when creating a packfile and
corresponding index.
2017-02-28 13:27:50 +00:00
Edward Thomson
e6ed0d2f03 odb_loose: fsync tests
Introduce a simple counter that `p_fsync` implements.  This is useful
for ensuring that `p_fsync` is called when we expect it to be, for
example when we have enabled an odb backend to perform `fsync`s when
writing objects.
2017-02-28 13:27:49 +00:00
Edward Thomson
6d3ad7e09e Add ENABLE_SYNCHRONIZED_OBJECT_CREATION option
Allow users to enable `SYNCHRONIZED_OBJECT_CREATION` with a setting.
2017-02-28 13:27:49 +00:00