Commit Graph

8964 Commits

Author SHA1 Message Date
Edward Thomson
7f2c1469f8 Merge pull request #3528 from chescock/Passthrough-from-credential-callback
Treat GIT_PASSTHROUGH as though git_cred_acquire_cb isn't set.
2015-12-14 13:54:02 -06:00
Edward Thomson
30c8e26074 Merge pull request #3521 from pks-t/blame-line-overflow
Line count overflow in git_blame_hunk and git_blame__entry
2015-12-14 13:53:26 -06:00
Carlos Martín Nieto
6aa06b65cf Merge pull request #3522 from pks-t/email-format-commit-message
diff: include commit message when formatting patch
2015-12-10 12:14:09 +01:00
Carlos Martín Nieto
dc49eb585f Merge pull request #3538 from pks-t/pks/index-memory-leak
index: always queue `remove_entry` for removal
2015-12-10 11:57:44 +01:00
Carlos Martín Nieto
0a294217d8 Merge pull request #3542 from libgit2/cmn/reset-dir-file
reset: perform the checkout before moving HEAD or the index
2015-12-09 20:56:04 +01:00
Carlos Martín Nieto
465c3b38d5 reset: perform the checkout before moving HEAD or the index
This keeps the state of the workdir the same as one from HEAD, removing
a source of possible confusion when calculating the work that is to be
done.
2015-12-09 19:16:11 +01:00
Carlos Martín Nieto
828852553a CHANGELOG: add some things we missed 2015-12-09 13:57:15 +01:00
Carlos Martín Nieto
21b1e015a3 Merge pull request #3539 from libgit2/typedef-submodule-cb
Use a typedef for the submodule_foreach callback.
2015-12-08 21:11:58 +01:00
Edward Thomson
d698929cdd Merge pull request #3537 from libgit2/cmn/tree-is-sorted
tree: mark a tree as already sorted
2015-12-08 13:12:27 -05:00
joshaber
ab273821ee Play nice with the docs. 2015-12-08 11:58:19 -05:00
joshaber
eda726cfb5 Use a typedef for the submodule_foreach callback.
This fits with the style for the rest of the project, but more
importantly, makes life easier for bindings authors who auto-generate
code.
2015-12-08 11:34:00 -05:00
Patrick Steinhardt
b057fdef69 index: always queue remove_entry for removal
When replacing an index with a new one, we need to iterate
through all index entries in order to determine which entries are
equal. When it is not possible to re-use old entries for the new
index, we move it into a list of entries that are to be removed
and thus free'd.

When we encounter a non-zero error code, though, we skip adding
the current index entry to the remove-queue. `INSERT_MAP_EX`,
which is the function last run before adding to the remove-queue,
may return a positive non-zero code that indicates what exactly
happened while inserting the element. In this case we skip adding
the entry to the remove-queue but still continue the current
operation, leading to a leak of the current entry.

Fix this by checking for a negative return value instead of a
non-zero one when we want to add the current index entry to the
remove-queue.
2015-12-08 16:29:08 +01:00
Carlos Martín Nieto
fc43646965 tree: mark a tree as already sorted
The trees are sorted on-disk, so we don't have to go over them
again. This cuts almost a fifth of time spent parsing trees.
2015-12-06 23:17:19 +01:00
Carlos Martín Nieto
a3dc4190e7 Merge pull request #3526 from sschuberth/cmake-number-compare
CMakeLists: Compare CMAKE_SIZEOF_VOID_P as a number, not as a string
2015-12-06 18:11:54 +01:00
Carlos Martín Nieto
8febe654be Merge pull request #3529 from mgorny/fix-checkout-test-umask
checkout test: Apply umask to file-mode test as well
2015-12-06 18:11:37 +01:00
Edward Thomson
5d1f31c6e6 Merge pull request #3530 from libgit2/cmn/parse-mode
tree: use a specialised mode parse function
2015-12-03 17:42:52 -05:00
Carlos Martín Nieto
2d36e145d9 Merge pull request #3534 from ethomson/index_canonicalize_fix
index: canonicalize inserted paths safely
2015-12-03 23:37:37 +01:00
Edward Thomson
626f9e243e index: canonicalize inserted paths safely
When adding to the index, we look to see if a portion of the given
path matches a portion of a path in the index.  If so, we will use
the existing path information.  For example, when adding `foo/bar.c`,
if there is an index entry to `FOO/other` and the filesystem is case
insensitive, then we will put `bar.c` into the existing tree instead
of creating a new one with a different case.

Use `strncmp` to do that instead of `memcmp`.  When we `bsearch`
into the index, we locate the position where the new entry would
go.  The index entry at that position does not necessarily have
a relation to the entry we're adding, so we cannot make assumptions
and use `memcmp`.  Instead, compare them as strings.

When canonicalizing paths, we look for the first index entry that
matches a given substring.
2015-12-03 16:27:15 -05:00
Carlos Martín Nieto
0174f21b0a tree: use a specialised mode parse function
Instead of going out to strtol, which is made to parse generic numbers,
copy a parse function from git which is specialised for file modes.
2015-12-02 18:59:58 +01:00
Sebastian Schuberth
0878ca9b7c CMakeLists: Compare CMAKE_SIZEOF_VOID_P as a number, not as a string 2015-12-02 14:50:25 +01:00
Michał Górny
326c9fc2ed checkout test: Apply umask to file-mode test as well
Fix the file-mode test to expect system umask being applied to the
created file as well (it is currently applied to the directory only).
This fixes the test on systems where umask != 022.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2015-12-01 20:42:56 +01:00
Chris Hescock
efd9ab568b Treat GIT_PASSTHROUGH as though git_cred_acquire_cb isn't set. 2015-12-01 10:54:20 -05:00
Edward Thomson
15e6a5afb9 Merge pull request #3527 from pks-t/pks/tree-entry-memleak
tree: mark cloned tree entries as un-pooled
2015-12-01 08:45:55 -05:00
Patrick Steinhardt
9487585ddc tree: mark cloned tree entries as un-pooled
When duplicating a `struct git_tree_entry` with
`git_tree_entry_dup` the resulting structure is not allocated
inside a memory pool. As we do a 1:1 copy of the original struct,
though, we also copy the `pooled` field, which is set to `true`
for pooled entries. This results in a huge memory leak as we
never free tree entries that were duplicated from a pooled
tree entry.

Fix this by marking the newly duplicated entry as un-pooled.
2015-12-01 14:25:15 +01:00
Patrick Steinhardt
254e0a33ee diff: include commit message when formatting patch
When formatting a patch as email we do not include the commit's
message in the formatted patch output. Implement this and add a
test that verifies behavior.
2015-12-01 10:12:53 +01:00
Patrick Steinhardt
7f8fe1d45e commit: introduce git_commit_body
It is already possible to get a commit's summary with the
`git_commit_summary` function. It is not possible to get the
remaining part of the commit message, that is the commit
message's body.

Fix this by introducing a new function `git_commit_body`.
2015-12-01 10:07:00 +01:00
Patrick Steinhardt
944dbd1259 blame: use size_t for line counts in git_blame__entry
The `git_blame__entry` struct keeps track of line counts with
`int` fields. Since `int` is only guaranteed to be at least 16
bits we may overflow on certain platforms when line counts exceed
2^15.

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

Fix this by converting the line fields of `git_blame_hunk` to
`size_t`. Add test to verify behavior.
2015-12-01 09:02:47 +01:00
Edward Thomson
337b2b08f4 Merge pull request #3508 from libgit2/cmn/tree-parse-speed
Improvements to tree parsing speed
2015-11-30 20:53:54 -05:00
Carlos Martín Nieto
a589f22a94 Merge pull request #3525 from pks-t/pks/fix-nested-struct-warning
Compiler warning fixes
2015-11-30 20:41:54 +01:00
Patrick Steinhardt
bbd2fa4e70 object: remove unused constant OBJECT_BASE_SIZE 2015-11-30 18:05:27 +01:00
Patrick Steinhardt
a7bd157ebf tests: fix warning for nested struct initialization 2015-11-30 17:40:49 +01:00
Carlos Martín Nieto
95ae3520c5 tree: ensure the entry filename fits in 16 bits
Return an error in case the length is too big. Also take this
opportunity to have a single allocating function for the size and
overflow logic.
2015-11-30 17:32:18 +01:00
Carlos Martín Nieto
a27f31d8f5 Merge pull request #3513 from ethomson/merge_recursive
Recursive Merge
2015-11-30 04:49:31 +01:00
Carlos Martín Nieto
ee42bb0e3d tree: make path len uint16_t and avoid holes
This reduces the size of the struct from 32 to 26 bytes, and leaves a
single padding byte at the end of the struct (which comes from the
zero-length array).
2015-11-28 19:21:52 +01:00
Carlos Martín Nieto
2580077fc2 tree: calculate the filename length once
We already know the size due to the `memchr()` so use that information
instead of calling `strlen()` on it.
2015-11-28 19:21:52 +01:00
Carlos Martín Nieto
ed970748b6 tree: pool the entry memory allocations
These are rather small allocations, so we end up spending a non-trivial
amount of time asking the OS for memory. Since these entries are tied to
the lifetime of their tree, we can give the tree a pool so we speed up
the allocations.
2015-11-28 19:21:51 +01:00
Carlos Martín Nieto
7132150ddf tree: avoid advancing over the filename multiple times
We've already looked at the filename with `memchr()` and then used
`strlen()` to allocate the entry. We already know how much we have to
advance to get to the object id, so add the filename length instead of
looking at each byte again.
2015-11-28 19:21:51 +01:00
Edward Thomson
5b9c63c3f6 recursive merge: add a recursion limit 2015-11-25 16:25:47 -05:00
Edward Thomson
78859c6344 merge: handle conflicts in recursive base building
When building a recursive merge base, allow conflicts to occur.
Use the file (with conflict markers) as the common ancestor.

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

If they did not resolve the conflict identically in the two branches,
then we will generate a new conflict.  If the user is simply using
standard conflict output then the results will be fairly sensible.
But if the user is using a mergetool or using diff3 output, then the
common ancestor will be a conflict file (itself with diff3 output,
haha!).  This is quite terrible, but it matches git's behavior.
2015-11-25 15:38:39 -05:00
Edward Thomson
34a51428a1 merge tests: add complex recursive example 2015-11-25 15:38:33 -05:00
Edward Thomson
651bfd699c recursive: test conflict output during recursive merge 2015-11-25 15:38:28 -05:00
Edward Thomson
dcde572042 merge tests: move expected data into own file 2015-11-25 15:38:22 -05:00
Edward Thomson
76ade3a0b8 merge: use annotated commits for recursion
Use annotated commits to act as our virtual bases, instead of regular
commits, to avoid polluting the odb with virtual base commits and
trees.  Instead, build an annotated commit with an index and pointers
to the commits that it was merged from.
2015-11-25 15:38:16 -05:00
Edward Thomson
7730fe8e9c merge: merge annotated commits instead of regular commits 2015-11-25 15:38:03 -05:00
Edward Thomson
3f2bb387a4 merge: octopus merge common ancestors when >2
When there are more than two common ancestors, continue merging the
virtual base with the additional common ancestors, effectively
octopus merging a new virtual base.
2015-11-25 15:37:57 -05:00
Edward Thomson
b1eef912cf merge: add recursive test with conflicting contents 2015-11-25 15:37:51 -05:00
Edward Thomson
1b82f7b6a2 merge: compute octopus merge bases 2015-11-25 15:37:45 -05:00
Edward Thomson
fccad82ee8 merge: add recursive test with three merge bases 2015-11-25 15:37:39 -05:00
Edward Thomson
99d9d9a470 merge: improve test names in recursive merge tests 2015-11-25 15:37:33 -05:00