Commit Graph

145 Commits

Author SHA1 Message Date
Carlos Martín Nieto
d53cc13e3a Merge pull request #3575 from pmq20/master-13jan16
Remove duplicated calls to git_mwindow_close
2016-03-31 04:12:46 -07:00
Carlos Martín Nieto
e50a49ee9b Merge pull request #3559 from yongthecoder/master
Add a sanity check in git_indexer_commit to avoid subtraction overflow.
2016-03-22 01:54:49 -07:00
Carlos Martín Nieto
87c181970d Split the page size from the mmap alignment
While often similar, these are not the same on Windows. We want to use the page
size on Windows for the pools, but for mmap we need to use the allocation
granularity as the alignment.

On the other platforms these values remain the same.
2016-03-16 21:36:25 +01:00
P.S.V.R
d4e4f27204 Remove duplicated calls to git_mwindow_close 2016-01-13 11:07:14 +08:00
Yong Li
b3eb2cde2b Avoid subtraction overflow in git_indexer_commit 2016-01-04 10:47:00 -05:00
Stefan Widgren
c369b37919 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-07-31 16:23:11 +02:00
Edward Thomson
3e8c5e45cb Merge pull request #3174 from libgit2/cmn/idx-fill-hole
indexer: use lseek to extend the packfile
2015-06-10 16:43:48 -04:00
Carlos Martín Nieto
02980bdca1 Initialize a few variables
Coverity complains about the git_rawobj ones because we use a loop in
which we keep remembering the old version, and we end up copying our
object as the base, so we want to have the data pointer be NULL.
2015-06-09 16:53:07 +02:00
Carlos Martín Nieto
aa57231fca indexer: use lseek to extend the packfile
We've been using `p_ftruncate()` to extend the packfile in order to mmap
it and write the new data into it. This works well in the general case,
but as truncation does not allocate space in the filesystem, it must do
so when we write data to it.

The only way the OS has to indicate a failure to allocate space is via
SIGBUS which means we tried to write outside the file. This will cause
everyone to crash as they don't expect to handle this signal.

Switch to using `p_lseek()` and `p_write()` to extend the file in a way
which tells the filesystem to allocate the space for the missing
data. We can then be sure that we have space to write into.
2015-06-02 10:25:22 +02:00
Edward Thomson
e2dd3735a5 indexer: avoid loading already existent bases
When thickening a pack, avoid loading already loaded bases and
trying to insert them all over again.
2015-05-22 15:27:52 -04:00
Edward Thomson
7800048afb Merge pull request #2972 from libgit2/cmn/pack-objects-walk
[WIP] Smarter pack-building
2015-03-17 10:06:50 -04:00
Carlos Martín Nieto
7c63a33ffe indexer: bring back the error message on duplcate commits
It turns out that erroring out on duplicate commits is the right thing
to do, but git was not hitting the bug on the server-side.

Bring back a descriptive error message in case of duplicate entries and
error out.
2015-03-13 19:41:40 +01:00
Carlos Martín Nieto
dccf59ad38 indexer: don't worry about duplicate objects
If a packfile includes duplicate objects, we can choose to use the
secon copy instead of the first by using the same logic as if it were
the first.

Change the error condition from 0 to -1, which indicates a bad resize,
and set the OOM message in that case.

This does mean we will leak the first copy of the object. We can deal
with that later, but making fetches work is more important.
2015-03-13 18:28:07 +01:00
Carlos Martín Nieto
a34692c419 indexer: set an error message on duplicate objects in pack
While this is not even close to a fix, we can at least set an error
message so we know which error we are facing. Up to know we just
returned an error without a message.
2015-03-13 18:00:15 +01:00
Carlos Martín Nieto
b63b76e0b0 Reorder some khash declarations
Keep the definitions in the headers, while putting the declarations in
the C files. Putting the function definitions in headers causes
them to be duplicated if you include two headers with them.
2015-03-11 02:36:11 +01:00
Edward Thomson
c251f3bbe7 win32: remember to cleanup our hash_ctx 2014-12-09 12:04:47 -05:00
Ravindra Patel
ec7e680c6c Fix for misleading "missing delta bases" error - Fix #2721. 2014-11-21 15:05:34 -05:00
Ravindra Patel
7561f98d6d Fix for memory leak issue in indexer.c, that surfaces on windows 2014-11-19 14:54:30 -05:00
Carlos Martín Nieto
177a29d832 Merge commit 'refs/pull/2366/head' of github.com:libgit2/libgit2 2014-10-27 10:39:45 +01:00
William Swanson
01b432cf35 Properly report failure when expanding a packfile 2014-07-09 14:12:30 -07:00
Philip Kelley
bc8a088685 Fix assert when receiving uncommon sideband packet 2014-06-27 12:03:27 -04:00
Carlos Martín Nieto
b3b66c5793 Share packs across repository instances
Opening the same repository multiple times will currently open the same
file multiple times, as well as map the same region of the file multiple
times. This is not necessary, as the packfile data is immutable.

Instead of opening and closing packfiles directly, introduce an
indirection and allocate packfiles globally. This does mean locking on
each packfile open, but we already use this lock for the global mwindow
list so it doesn't introduce a new contention point.
2014-06-23 21:50:36 +02:00
Albert Meltzer
62e562f92b Fix compiler warning (git_off_t cast to size_t).
Use size_t for page size, instead of long. Check result of sysconf.
Use size_t for page offset so no cast to size_t (second arg to p_mmap).
Use mod instead div/mult pair, so no cast to size_t is necessary.
2014-05-19 17:37:29 -07:00
Albert Meltzer
9c4feef9f8 Fix warning on uninitialized variable. 2014-05-18 07:27:06 -07:00
Carlos Martín Nieto
0731a5b4db indexer: mmap fixes for Windows
Windows has its own ftruncate() called _chsize_s().

p_mkstemp() is changed to use p_open() so we can make sure we open for
writing; the addition of exclusive create is a good thing to do
regardless, as we want a temporary path for ourselves.

Lastly, MSVC doesn't quite know how to add two numbers if one of them is a
void pointer, so let's alias it to unsigned char.C
2014-05-17 01:39:43 +02:00
Carlos Martín Nieto
f7310540ae indexer: use mmap for writing
Some OSs cannot keep their ideas about file content straight when mixing
standard IO with file mapping. As we use mmap for reading from the
packfile, let's make writing to the pack file use mmap.
2014-05-17 01:39:43 +02:00
Linquize
b3f27c4368 Initialize local variable 2014-05-13 21:08:50 +08:00
Carlos Martín Nieto
2dde1e0c1c indexer: avoid memory moves
Our vector does a move of the rest of the array when we remove an
item. Doing this repeatedly can be expensive, and we do this a lot in
the indexer. Instead, set the value to NULL and skip those entries.

perf reported around 30% of `index-pack` time was going into
memmove. With this change, that goes away and we spent most of the time
hashing and inflating data.
2014-05-08 22:40:13 +02:00
Jacques Germishuys
48e60ae75e Don't redefine the same callback types, their signatures may change 2014-04-21 11:28:49 +02:00
Russell Belfer
e9d5e5f3d4 Some fixes for Windows x64 warnings 2014-01-30 09:59:59 -08:00
Vicent Marti
557bd1f410 Merge pull request #2043 from arthurschreiber/arthur/fix-memory-leaks
Fix a bunch of memory leaks.
2014-01-14 10:27:57 -08:00
Arthur Schreiber
249537573b Incorporate @arrbee's suggestions. 2014-01-14 19:08:58 +01:00
Edward Thomson
c6f26b48e4 Refactor zlib for easier deflate streaming 2014-01-14 09:45:12 -08:00
Arthur Schreiber
ac44b3d244 Incorporate @ethomson's suggestions. 2014-01-13 23:28:03 +01:00
Arthur Schreiber
ddf1b1ffa5 Fix a memory leak in hash_and_save and inject_object. 2014-01-13 22:33:10 +01:00
Russell Belfer
9cfce2735d Cleanups, renames, and leak fixes
This renames git_vector_free_all to the better git_vector_free_deep
and also contains a couple of memory leak fixes based on valgrind
checks.  The fixes are specifically: failure to free global dir
path variables when not compiled with threading on and failure to
free filters from the filter registry that had not be initialized
fully.
2013-12-12 12:11:38 -08:00
Russell Belfer
7697e54176 Test cancel from indexer progress callback
This adds tests that try canceling an indexer operation from
within the progress callback.

After writing the tests, I wanted to run this under valgrind and
had a number of errors in that situation because mmap wasn't
working.  I added a CMake option to force emulation of mmap and
consolidated the Amiga-specific code into that new place (so we
don't actually need separate Amiga code now, just have to turn on
-DNO_MMAP).

Additionally, I made the indexer code propagate error codes more
reliably than it used to.
2013-12-11 15:02:20 -08:00
Russell Belfer
26c1cb91be One more rename/cleanup for callback err functions 2013-12-11 10:57:50 -08:00
Russell Belfer
25e0b1576d Remove converting user error to GIT_EUSER
This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
2013-12-11 10:57:49 -08:00
Russell Belfer
fcd324c625 Add git_vector_free_all
There are a lot of places that we call git__free on each item in
a vector and then call git_vector_free on the vector itself.  This
just wraps that up into one convenient helper function.
2013-12-11 10:57:49 -08:00
Russell Belfer
dab89f9b68 Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper.  As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.

Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up.  A number of
those fixes are included in the this commit as well.
2013-12-11 10:57:49 -08:00
Jameson Miller
db4cbfe504 Updates to cancellation logic during download and indexing of packfile. 2013-12-02 23:05:10 -05:00
Edward Thomson
1e60e5f42d Allow callers to set mode on packfile creation 2013-11-07 12:04:32 -05:00
Edward Thomson
1d3a8aeb4b move mode_t to filebuf_open instead of _commit 2013-11-04 22:33:05 -05:00
Russell Belfer
948f00b4e7 Merge pull request #1933 from libgit2/vmg/gcc-warnings
Warnings for Windows x64 (MSVC) and GCC on Linux
2013-11-01 09:38:03 -07:00
Vicent Marti
51a3dfb595 pack: __object_header always returns unsigned values 2013-11-01 17:36:09 +01:00
Linquize
3343b5ffd3 Fix warning on win64 2013-11-01 17:36:04 +01:00
Carlos Martín Nieto
a6154f2183 indexer: remove the stream infix
It was there to keep it apart from the one which read in from a file on
disk. This other indexer does not exist anymore, so there is no need for
anything other than git_indexer to refer to it.

While here, rename _add() function to _append() and _finalize() to
_commit(). The former change is cosmetic, while the latter avoids
talking about "finalizing", which OO languages use to mean something
completely different.
2013-10-30 15:00:05 +01:00
Vicent Martí
5c50f22a93 Merge pull request #1891 from libgit2/cmn/fix-thin-packs
Add support for thin packs
2013-10-28 09:25:44 -07:00
Carlos Martín Nieto
ab46b1d8eb indexer: include the delta stats
The user is unable to derive the number of deltas in the pack, as that
would require them to capture the stats exactly in the moment between
download and final processing, which is abstracted away in the fetch.

Capture these numbers for the user and expose them in the progress
struct. The clone and fetch examples now also present this information
to the user.
2013-10-23 15:08:18 +02:00