Commit Graph

9426 Commits

Author SHA1 Message Date
Edward Thomson
80745b1256 index_read_index: set flags for path_len correctly
Update the flags to reset the path_len (to emulate `index_insert`)
2016-10-01 17:40:36 +02:00
Edward Thomson
e755f79fd7 index_read_index: differentiate on mode
Treat index entries with different modes as different, which they
are, at least for the purposes of up-to-date calculations.
2016-10-01 17:40:36 +02:00
Edward Thomson
e6a0a85091 index_read_index: reset error correctly
Clear any error state upon each iteration.  If one of the iterations
ends (with an error of `GIT_ITEROVER`) we need to reset that error to 0,
lest we stop the whole process prematurely.
2016-10-01 17:40:36 +02:00
Edward Thomson
6c133a7575 round-trip trees through index_read_index
Read a tree into an index using `git_index_read_index` (by reading
a tree into a new index, then reading that index into the current
index), then write the index back out, ensuring that our new index
is treesame to the tree that we read.
2016-10-01 17:40:36 +02:00
Edward Thomson
feea2849f9 win32: clean up unused warnings in DllMain 2016-10-01 17:40:36 +02:00
Edward Thomson
efadf28d84 filebuf: fix uninitialized warning 2016-10-01 17:40:36 +02:00
Edward Thomson
bcef008f77 cleanup: unused warning 2016-10-01 17:40:35 +02:00
Elan Ruusamäe
68227c431a Update CMakeLists.txt
typo fix
2016-10-01 17:40:35 +02:00
Jason Haslam
85ef6ec5f0 Ignore submodules when checking for merge conflicts in the workdir. 2016-10-01 17:40:35 +02:00
Jason Haslam
70681ff740 checkout: handle dirty submodules correctly
Don't generate conflicts when checking out a modified submodule and the
submodule is dirty or modified in the workdir.
2016-10-01 17:40:35 +02:00
François Revol
26917fd9d1 test: Fix stat() test to mask out unwanted bits
Haiku and Hurd both pass extra bits in struct stat::st_mode.
2016-10-01 17:40:35 +02:00
François Revol
488937c22d CMakeLists: Add libnetwork for Haiku 2016-10-01 17:40:35 +02:00
Carl Edquist
78b5702ed5 Fix comment for GIT_FILEMODE_LINK
0120000 is symbolic link, not commit
2016-10-01 17:40:34 +02:00
Lucas Derraugh
849a1a4345 Fix unused variable 'message' warning 2016-10-01 17:40:34 +02:00
Patrick Steinhardt
cf0396a563 delta-apply: fix sign extension
We compute offsets by executing `off |= (*delta++ << 24)` for
multiple constants, where `off` is of type `size_t` and `delta`
is of type `unsigned char`. The usual arithmetic conversions (see
ISO C89 §3.2.1.5 "Usual arithmetic conversions") kick in here,
causing us to promote both operands to `int` and then extending
the result to an `unsigned long` when OR'ing it with `off`.
The integer promotion to `int` may result in wrong size
calculations for big values.

Fix the issue by making the constants `unsigned long`, causing both
operands to be promoted to `unsigned long`.
2016-10-01 17:40:34 +02:00
Patrick Steinhardt
1fb8a951b6 odb_loose: fix undefined behavior when computing size
An object's size is computed by reading the object header's size
field until the most significant bit is not set anymore. To get
the total size, we increase the shift on each iteration and add
the shifted value to the total size.

We read the current value into a variable of type `unsigned
char`, from which we then take all bits except the most
significant bit and shift the result. We will end up with a
maximum shift of 60, but this exceeds the width of the value's
type, resulting in undefined behavior.

Fix the issue by instead reading the values into a variable of
type `unsigned long`, which matches the required width. This is
equivalent to git.git, which uses an `unsigned long` as well.
2016-10-01 17:40:34 +02:00
Patrick Steinhardt
f627e19662 checkout: set ignorecase=0 when config lookup fails
When `git_repository__cvar` fails we may end up with a
`ignorecase` value of `-1`. As we subsequently check if
`ignorecase` is non-zero, we may end up reporting that data
should be removed when in fact it should not.

Err on the safer side and set `ignorecase = 0` when
`git_repository__cvar` fails.
2016-10-01 17:40:34 +02:00
Carlos Martín Nieto
66633e836f odb: avoid inflating the full delta to read the header
When we read the header, we want to know the size and type of the
object. We're currently inflating the full delta in order to read the
first few bytes. This can mean hundreds of kB needlessly inflated for
large objects.

Instead use a packfile stream to read just enough so we can read the two
varints in the header and avoid inflating most of the delta.
2016-10-01 17:40:34 +02:00
Patrick Steinhardt
fc2ef5143b index: fix memory leak on error case 2016-10-01 17:40:34 +02:00
Edward Thomson
1aacaa3154 cmake: include threading libraries in pkg-config
Include any required threading libraries in our `libgit2.pc`.
2016-10-01 17:40:33 +02:00
Christian Schlack
b726c53991 Fix return value of openssl_read (infinite loop)
openssl_read should return -1 in case of error.

SSL_read returns values <= 0 in case of error.

A return value of 0 can lead to an infinite loop, so the return value
of ssl_set_error will be returned if SSL_read is not successful (analog
to openssl_write).
2016-10-01 17:40:33 +02:00
Carlos Martín Nieto
16541b864d tag: ignore extra header fields
While no extra header fields are defined for tags, git accepts them by
ignoring them and continuing the search for the message. There are a few
tags like this in the wild which git parses just fine, so we should do
the same.
2016-10-01 17:40:33 +02:00
Andreas Henriksson
301b9067fe Upload to unstable 2016-04-13 11:31:55 +02:00
Andreas Henriksson
25dcab5fc4 Update debian/changelog 2016-04-12 16:37:11 +02:00
Andreas Henriksson
903d97a725 Revert "Disable fakeroot emulation when running tests"
This reverts commit 267c427582.

No longer needed, upstream testsuite fixed to assume failure
when running as root is ok. See:
https://github.com/libgit2/libgit2/commit/5cc7a5c7b389066ab7
2016-04-12 16:33:06 +02:00
Andreas Henriksson
62a960f111 Drop git_tests-fix-core-stream-test-when-built-with-openssl-o.patch
- merged upstream.

Git-Dch: full
2016-04-12 16:32:16 +02:00
Andreas Henriksson
a2315f05bb Update debian/changelog 2016-04-12 16:31:59 +02:00
Andreas Henriksson
6f92394e3b Merge tag 'upstream/0.24.1'
Upstream version 0.24.1
2016-04-12 16:31:06 +02:00
Andreas Henriksson
c7f45bda7d Imported Upstream version 0.24.1 2016-04-12 16:31:05 +02:00
Carlos Martín Nieto
211e117a05 Merge pull request #3739 from ethomson/0.24.1
Backport bug fixes to 0.24
2016-04-12 00:18:17 +02:00
Edward Thomson
8edadbf978 index::racy: force racy entry
Instead of hoping that we can get a racy entry by going real fast
and praying real hard, just create a racy entry.
2016-04-11 16:40:30 -04:00
Edward Thomson
ccfacb8bb1 leaks: call xdl_free_classifier 2016-04-11 16:17:04 -04:00
Edward Thomson
6a35e74cb3 leaks: fix some leaks in the tests 2016-04-11 16:16:55 -04:00
Carlos Martín Nieto
2c1bc36d56 Plug a few leaks 2016-04-11 16:15:33 -04:00
Edward Thomson
5cc7a5c7b3 tests: skip the unreadable file tests as root
When running as root, skip the unreadable file tests, because, well,
they're probably _not_ unreadable to root unless you've got some
crazy NSA clearance-level honoring operating system shit going on.
2016-04-11 16:05:51 -04:00
Edward Thomson
1d59c85aad status: update test to include valid OID 2016-04-11 15:59:12 -04:00
Edward Thomson
af753aba14 tree: drop the now-unnecessary entries vector
Remove the now-unnecessary entries vector.  Add `git_array_search`
to binary search through an array to accomplish this.
2016-04-11 15:58:59 -04:00
Carlos Martín Nieto
13ebf7bdbc tree: store the entries in a growable array
Take advantage of the constant size of tree-owned arrays and store them
in an array instead of a pool. This still lets us free them all at once
but lets the system allocator do the work of fitting them in.
2016-04-11 15:58:58 -04:00
Carlos Martín Nieto
26f2cefb81 tree: re-use the id and filename in the odb object
Instead of copying over the data into the individual entries, point to
the originals, which are already in a format we can use.
2016-04-11 15:58:58 -04:00
Carlos Martín Nieto
177890838a ignore: don't use realpath to canonicalize path
If we're looking for a symlink, realpath will give us the resolved path,
which is not what we're after, but a canonicalized version of the path
the user asked for.
2016-04-11 15:58:58 -04:00
Edward Thomson
21d8832e74 config::write::repeated: init our buffer 2016-04-11 15:58:58 -04:00
Edward Thomson
a13c1ec206 config: don't write section header if we're in it
If we hit the EOF while trying to write a new value, it may be that
we're already in the section that we were looking for.  If so, do not
write a (duplicate) section header, just write the value.
2016-04-11 15:58:58 -04:00
Carlos Martín Nieto
e8d5df9edc config: show we write a spurious duplicated section header
We should notice that we are in the correct section to add. This is a
cosmetic bug, since replacing any of these settings does work.
2016-04-11 15:58:58 -04:00
Edward Thomson
b6130fe15e refs::create: strict object creation on by default
When we turned strict object creation validation on by default, we
forgot to inform the refs::create tests of this.  They, in fact,
believed that strict object creation was off by default.  As a result,
their cleanup function went and turned strict object creation off for
the remaining tests.
2016-04-11 15:58:58 -04:00
Carlos Martín Nieto
ba52879b46 reset: use real ids for the tests
This lets us run with strict object creation on.
2016-04-11 15:58:58 -04:00
Carlos Martín Nieto
3e2e8240c0 refs: provide a more general error message for dwim
If we cannot dwim the input, set the error message to be explicit about
that. Otherwise we leave the error for the last failed lookup, which
can be rather unexpected as it mentions a remote when the user thought
they were trying to look up a branch.
2016-04-11 15:58:57 -04:00
Andreas Henriksson
ab062a3938 tests: fix core/stream test when built with openssl off
When passing -DUSE_OPENSSL:BOOL=OFF to cmake the testsuite will
fail with the following error:

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

Fix test to assume failure for tls when built without openssl.
While at it also fix GIT_WIN32 cpp to check if it's defined
or not.
2016-04-11 15:58:57 -04:00
Carlos Martín Nieto
fe1f47776f Add a no-op size_t typedef for the doc parser
Clang's documentation parser, which we use in our documentation system
does not report any comments for functions which use size_t as a type.

The root cause is buried somewhere in libclang but we can work around it
by defining the type ourselves. This typedef makes sure that libclang
sees it and that we do not change its size.
2016-04-11 15:58:57 -04:00
Patrick Steinhardt
56da07cbcb xdiff/xprepare: fix a memory leak
The xdl_prepare_env() function may initialise an xdlclassifier_t
data structure via xdl_init_classifier(), which allocates memory
to several fields, for example 'rchash', 'rcrecs' and 'ncha'.
If this function later exits due to the failure of xdl_optimize_ctxs(),
then this xdlclassifier_t structure, and the memory allocated to it,
is not cleaned up.

In order to fix the memory leak, insert a call to xdl_free_classifier()
before returning.

This patch was originally written by Ramsay Jones (see commit
87f16258367a3b9a62663b11f898a4a6f3c19d31 in git.git).
2016-04-11 15:58:57 -04:00
Patrick Steinhardt
3ec0f2e37d xdiff/xprepare: use the XDF_DIFF_ALG() macro to access flag bits
Commit 307ab20b3 ("xdiff: PATIENCE/HISTOGRAM are not independent option
bits", 19-02-2012) introduced the XDF_DIFF_ALG() macro to access the
flag bits used to represent the diff algorithm requested. In addition,
code which had used explicit manipulation of the flag bits was changed
to use the macros.

However, one example of direct manipulation remains. Update this code to
use the XDF_DIFF_ALG() macro.

This patch was originally written by Ramsay Jones (see commit
5cd6978a9cfef58de061a9525f3678ade479564d in git.git).
2016-04-11 15:58:57 -04:00