Commit Graph

3640 Commits

Author SHA1 Message Date
Edward Thomson
e3f3868a1c 'del' instead of 'delete' for the poor C++ users 2013-09-24 11:04:14 -04:00
Russell Belfer
00e859279e Clean up unnecessary git_buf_printf calls
This replaces some git_buf_printf calls with simple calls to
git_buf_put instead.  Also, it fixes a missing va_end inside
the git_buf_vprintf implementation.
2013-09-23 21:52:42 -07:00
Russell Belfer
713793133f Fix warnings on Windows 64-bit build 2013-09-23 21:41:52 -07:00
Russell Belfer
1ca3e49f88 Clean up newly introduced warnings
The attempt to "clean up warnings" seems to have introduced some
new warnings on compliant compilers.  This fixes those in a way
that I suspect will also be okay for the non-compliant compilers.

Also this fixes what appears to be an extra semicolon in the
repo initialization template dir handling (and as part of that
fix, handles the case where an error occurs correctly).
2013-09-23 21:41:43 -07:00
Russell Belfer
106c12f118 Remove regex usage from places that don't need it
In revwalk, we are doing a very simple check to see if a string
contains wildcard characters, so a full regular expression match
is not needed.

In remote listing, now that we have git_config_foreach_match with
full regular expression matching, we can take advantage of that
and eliminate the regex here, replacing it with much simpler string
manipulation.
2013-09-23 13:31:15 -07:00
Vicent Martí
10edb7a92a Merge pull request #1863 from linquize/typo
Fix typo in documentation
2013-09-22 13:46:39 -07:00
Carlos Martín Nieto
07fb67f90e merge: reverse array and length parameter order
Make it pair up with the one for commits. This fixes #1691.
2013-09-22 05:59:35 +02:00
Linquize
1b57699a3a Fix typo in documentation 2013-09-22 09:38:51 +08:00
Vicent Martí
92d19d1671 Merge pull request #1840 from linquize/warning
Fix warning
2013-09-21 09:34:03 -07:00
Vicent Martí
2c9ed02eae Merge pull request #1859 from linquize/init.templatedir
Make init.templatedir work
2013-09-20 09:22:19 -07:00
Linquize
417472e317 Check error value from git_futils_find_template_dir 2013-09-20 09:02:58 +08:00
Linquize
66566516ce Fix warning 2013-09-19 23:14:06 +08:00
Linquize
0cd1c3bb06 Make init.templatedir work 2013-09-19 19:17:09 +08:00
Vicent Marti
5a284edca4 msvc: No void* arithmetic on Windows 2013-09-18 03:54:17 +02:00
Vicent Martí
4cf9323be1 Merge pull request #1860 from libgit2/cmn/indexer-hash
indexer: check the packfile trailer
2013-09-17 18:49:47 -07:00
Carlos Martín Nieto
e0aa6fc136 indexer: don't reiterate the class in the message 2013-09-18 02:27:31 +02:00
Carlos Martín Nieto
98eb2c59e8 indexer: check the packfile trailer for correctness
The packfile trailer gets sent over and we should check whether it's
correct as part of our sanity checks of the packfile.
2013-09-18 02:27:31 +02:00
Vicent Martí
3d4f169867 Merge pull request #1858 from linquize/win32-template-dir
Configurable template dir for Win32
2013-09-17 10:21:22 -07:00
Russell Belfer
eefc32d549 Bug fixes and cleanups
This contains a few bug fixes and some header and API cleanups.

The main API change is that filters should now use GIT_PASSTHROUGH
to indicate that they wish to skip processing a file instead of
GIT_ENOTFOUND.

The bug fixes include a possible out-of-range buffer access in
the ident filter, a filter ordering problem I introduced into the
custom filter tests on Windows, and a filter buf NUL termination
issue that was coming up on Linux.
2013-09-17 09:31:46 -07:00
Russell Belfer
eab3746b30 More filtering tests including order
This adds more tests of filters, including the ident filter when
mixed with custom filters.  I was able to combine with the reverse
filter and demonstrate that the order of filter application with
the default priority constants matches the order of core Git.

Also, this fixes two issues in the ident filter: preventing ident
expansion on binary files and avoiding a NULL dereference when
dollar sign characters are found without Id.
2013-09-17 09:31:46 -07:00
Russell Belfer
37f9e40939 Some tests with ident and crlf filters
Fixed the filter order to match core Git, too.

This test demonstrates an interesting behavior of core Git (which
is totally reasonable and which libgit2 matches, although mostly
by coincidence).  If you use the ident filter and commit a file
with a garbage ident in it, like '$Id: this is just garbage$' and
then immediately do a 'git checkout-index' with the new file, Git
will not consider the file out of date and will not overwrite the
file with an updated $Id$.  Libgit2 has the same behavior.  If you
remove the file and then do a checkout-index, it will be replaced
with a filtered version that has injected the OID correctly.
2013-09-17 09:31:46 -07:00
Russell Belfer
13f36ffb9e Add clar helpers for testing file equality
These are a couple of new clar helpers for testing that a file
has expected contents that I extracted from the checkout code.

Actually wrote this as part of an abandoned earlier attempt at a
new filters API, but it will be useful now for some of the tests
I'm going to write.
2013-09-17 09:31:46 -07:00
Russell Belfer
e399c7eee8 Fix win32 warnings
I wish MSVC understood that "const char **" is not a const ptr,
but it a non-const pointer to an array of const ptrs.  Does that
seem like too much to ask.
2013-09-17 09:31:46 -07:00
Russell Belfer
b47349b8dc Port tests from PR 1683
This ports over some of the tests from
    https://github.com/libgit2/libgit2/pull/1683
by @yorah and @ethomson
2013-09-17 09:31:45 -07:00
Russell Belfer
0e32635fcf Move binary check to CRLF filter itself
Checkout should not reject binary files from filters, as a filter
may actually wish to operate on binary files.  The CRLF filter should
reject binary files itself if it wishes to.  Moreover, the CRLF
filter requires this logic so that users can emulate the checkout
data in their odb -> workdir filtering.

Conflicts:
	src/checkout.c
	src/crlf.c
2013-09-17 09:31:45 -07:00
Russell Belfer
a9f51e430f Merge git_buf and git_buffer
This makes the git_buf struct that was used internally into an
externally available structure and eliminates the git_buffer.

As part of that, some of the special cases that arose with the
externally used git_buffer were blended into the git_buf, such as
being careful about git_buf objects that may have a NULL ptr and
allowing for bufs with a valid ptr and size but zero asize as a
way of referring to externally owned data.
2013-09-17 09:31:45 -07:00
Russell Belfer
4b11f25a4f Add ident filter
This adds the ident filter (that knows how to replace $Id$) and
tweaks the filter APIs and code so that git_filter_source objects
actually have the updated OID of the object being filtered when
it is a known value.
2013-09-17 09:31:45 -07:00
Russell Belfer
40cb40fab9 Add functions to manipulate filter lists
Extend the git2/sys/filter API with functions to look up a filter
and add it manually to a filter list.  This requires some trickery
because the regular attribute lookups and checks are bypassed when
this happens, but in the right hands, it will allow a user to have
granular control over applying filters.
2013-09-17 09:31:45 -07:00
Russell Belfer
0646634e2f Update filter registry code
This updates the git filter registry to be a little cleaner and
plugs some memory leaks.
2013-09-17 09:31:45 -07:00
Russell Belfer
a3aa5f4d5d Add simple global shutdown hooks
Increasingly there are a number of components that want to do some
cleanup at global shutdown time (at least if there are not going
to be memory leaks).  This creates a very simple system of shutdown
hooks that will be invoked by git_threads_shutdown.  Right now, the
maximum number of hooks is hardcoded, but since adding a hook is
not a public API, it should be fine and I thought it was better to
start off with really simple code.
2013-09-17 09:31:45 -07:00
Russell Belfer
e7d0ced219 Fix longstanding valgrind warning
There was a possible circumstance that could result in reading
past the end of a buffer.  This check fixes that.
2013-09-17 09:31:44 -07:00
Russell Belfer
29e92d385e Hook up filter initialize callback
I knew I forgot something
2013-09-17 09:31:44 -07:00
Russell Belfer
2a7d224f99 Extend public filter api with filter lists
This moves the git_filter_list into the public API so that users
can create, apply, and dispose of filter lists.  This allows more
granular application of filters to user data outside of libgit2
internals.

This also converts all the internal usage of filters to the public
APIs along with a few small tweaks to make it easier to use the
public git_buffer stuff alongside the internal git_buf.
2013-09-17 09:31:44 -07:00
Russell Belfer
974774c7b0 Add attributes to filters and fix registry
The filter registry as implemented was too primitive to actually
work once multiple filters were coming into play.  This expands
the implementation of the registry to handle multiple prioritized
filters correctly.

Additionally, this adds an "attributes" field to a filter that
makes it really really easy to implement filters that are based
on one or more attribute values.  The lookup and even simple value
checking can all happen automatically without custom filter code.

Lastly, with the registry improvements, this fills out the filter
lifecycle callbacks, with initialize and shutdown callbacks that
will be called before the filter is first used and after it is
last invoked.  This allows for system-wide initialization and
cleanup by the filter.
2013-09-17 09:31:44 -07:00
Russell Belfer
570ba25cb0 Make git_filter_source opaque 2013-09-17 09:30:06 -07:00
Russell Belfer
85d5481206 Create public filter object and use it
This creates include/sys/filter.h with a basic definition of a
git_filter and then converts the internal code to use it.  There
are related internal objects (git_filter_list) that we will want
to publish at some point, but this is a first step.
2013-09-17 09:30:06 -07:00
Russell Belfer
0cf77103b2 Start of filter API + git_blob_filtered_content
This begins the process of exposing git_filter objects to the
public API.  This includes:

* new public type and API for `git_buffer` through which an
  allocated buffer can be passed to the user
* new API `git_blob_filtered_content`
* make the git_filter type and GIT_FILTER_TO_... constants public
2013-09-17 09:30:06 -07:00
Linquize
a025907e0d Can load default template directory 2013-09-18 00:09:09 +08:00
Linquize
b99b10f285 Can git_libgit2_opts() with GIT_OPT_GET_TEMPLATE_PATH and GIT_OPT_SET_TEMPLATE_PATH 2013-09-18 00:00:41 +08:00
Linquize
7e8934bba2 Can guess win32 git template dir 2013-09-17 23:29:02 +08:00
Linquize
f84bc38853 Refactor git_win32__find_system_dirs() to extract "etc\\" as subpath parameter 2013-09-17 23:28:16 +08:00
Vicent Martí
4581f9d8ab Merge pull request #1833 from libgit2/cmn/config-include
Support config includes
2013-09-17 08:09:57 -07:00
Linquize
89095fbddc Fix failure in win32_find_git_in_registry() when UAC is turned on
Demand read only access to registry key instead of full access.
This might happen in Windows Vista and later.
2013-09-17 22:57:30 +08:00
Linquize
ffbd337aef Fix failure in win32_find_git_in_registry()
The buffer size 0 was definitely not enough so it failed
2013-09-17 22:57:06 +08:00
Vicent Martí
efc9e6700f Merge pull request #1856 from libgit2/cmn/no-orphans
No such thing as an orphan branch
2013-09-17 03:45:35 -07:00
Vicent Martí
38fba8371e Merge pull request #1851 from tiennou/libssh2-errors
Provide libssh2 error message
2013-09-17 03:40:50 -07:00
Carlos Martín Nieto
605da51a2c No such thing as an orphan branch
Unfortunately git-core uses the term "unborn branch" and "orphan
branch" interchangeably. However, "orphan" is only really there for
the checkout command, which has the `--orphan` option so it doesn't
actually create the branch.

Branches never have parents, so the distinction of a branch with no
parents is odd to begin with. Crucially, the error messages deal with
unborn branches, so let's use that.
2013-09-17 09:50:30 +02:00
Etienne Samson
eec4dcc34b Whitespace. 2013-09-16 23:07:22 +02:00
Etienne Samson
b622aabec0 Add a wrapper to provide the libssh2 error message 2013-09-16 23:07:19 +02:00
Vicent Marti
c62b5ca590 clone: Anal as fuck 2013-09-16 22:23:05 +02:00
Linquize
f2df503bab git_clone supports optional init_options 2013-09-16 08:02:36 +08:00
wilke
d7fc2eb29b Fix memory leak in git_tree_walk on error or when stopping the walk from the supplied callback 2013-09-13 21:36:39 +02:00
wilke
4e01e3029b Prevent git_tree_walk 'skip entry' callback return code from leaking through as the return value of git_tree_walk 2013-09-13 21:21:33 +02:00
Vicent Martí
a6ee166111 Merge pull request #1839 from isaac/ssh-repository-invalid
SSH: Clone fails with errors: ERROR: Repository invalid & Early EOF
2013-09-11 16:46:39 -07:00
nulltoken
8cf8052534 errors: Fix format of some error messages 2013-09-11 20:13:59 +02:00
Russell Belfer
6c38e60a00 Merge pull request #1838 from libgit2/cmn/first-parent
revwalk: allow simplifying by first-parent
2013-09-10 16:55:58 -07:00
nulltoken
209f9b67c4 odb: Teach loose backend to return EAMBIGUOUS 2013-09-10 22:36:13 +02:00
nulltoken
d0cd6c427a path: Make direach() return EUSER on callback error 2013-09-10 22:36:10 +02:00
Carlos Martín Nieto
15f7b9b8d9 revwalk: allow simplifying by first-parent
When enabled, only the first parent of each commit will be queued,
enabling a simple way of using first-parent simplification.
2013-09-09 20:31:14 +02:00
Isaac Kearse
b345026baa Test for repo before removing leading colon 2013-09-10 05:16:52 +12:00
Isaac Kearse
fbabe855ad Trim leading colon from ssh repository path 2013-09-08 14:11:08 +12:00
nulltoken
031f3f8028 odb: Error when streaming in too [few|many] bytes 2013-09-07 23:00:20 +02:00
Carlos Martín Nieto
53ea051371 config: handle realloc issues from larger depths
As the include depth increases, the chance of a realloc
increases. This means that whenever we run git_array_alloc() or call
config_parse(), we need to remember what our reader's index is so we
can look it up again.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
6978992298 config: return an error when reaching the maximum include depth 2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
73fc5e01c2 config: fix variable overriding
When two or more variables of the same name exist and the user asks
for a scalar, we must return the latest value assign to it.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
a9fb79896e config: refresh included files
We need to refresh the variables from the included files if they are
changed, so loop over all included files and re-parse the files if any
of them has changed.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
19be0692b4 config: keep a list of included files
When refreshing we need to refresh if any of the files have been
touched, so we need to keep the list.
2013-09-07 20:51:26 +02:00
Carlos Martín Nieto
d8d25acb9a config: add support for include directives
Relative, absolute and home-relative paths are supported. The
recursion limit it set at 10, just like in git.
2013-09-07 20:51:26 +02:00
nulltoken
1634df8c28 revparse: Simplify error handling 2013-09-07 17:48:06 +02:00
nulltoken
a8d67afe42 revparse: Prevent unnecessary odb backend calls 2013-09-07 17:48:05 +02:00
Russell Belfer
32e4992972 Merge pull request #1791 from libgit2/cmn/revwalk-recursive
revwalk: make mark_unintersting use a loop
2013-09-06 14:20:51 -07:00
nulltoken
4047950f30 odb: Prevent stream_finalize_write() from overwriting
Now that #1785 is merged, git_odb_stream_finalize_write() calculates the object id before invoking the odb backend.

This commit gives a chance to the backend to check if it already knows this object.
2013-09-06 22:47:28 +02:00
Carlos Martín Nieto
fb23d05f0b revwalk: make mark_unintersting use a loop
Using a recursive function can blow the stack when dealing with long
histories. Use a loop instead to limit the call chain depth.

This fixes #1223.
2013-09-06 19:56:51 +02:00
Vicent Martí
366bd2f43d Merge pull request #1829 from libgit2/fix-umask-fragility
Fix umask fragility
2013-09-05 16:56:21 -07:00
Russell Belfer
a7fcc44dcf Better macro name for is-exec-bit-set test 2013-09-05 16:14:32 -07:00
Russell Belfer
af22dabb43 GIT_MODE_TYPE should exclude setgid bits
The GIT_MODE_TYPE macro was looking at all bits above the
permissions, but it should really just look at the top bits so
that it will give the right results for a setgid or setuid entry.

Since we're now using these macros in the tests, this was causing
a test failure on platforms that don't support setgid.
2013-09-05 12:01:17 -07:00
Russell Belfer
f240acce86 Add more file mode permissions macros
This adds some more macros for some standard operations on file
modes, particularly related to permissions, and then updates a
number of places around the code base to use the new macros.
2013-09-05 11:20:12 -07:00
Carlos Martín Nieto
d209cc4751 config: decouple the backend from the reader at the low level
In order to support config includes, we must differentiate between the
backend's main file and the file we are currently parsing.

This lays the groundwork for includes, keeping the current behaviours.
2013-09-05 18:06:12 +02:00
Vicent Martí
cca9bea484 Merge pull request #1831 from linquize/version.h-warning
Fix warning in src/win32/version.h
2013-09-05 06:30:08 -07:00
Linquize
21753d4869 Fix warning in src/win32/version.h 2013-09-05 20:42:47 +08:00
Ben Straub
f42d546c63 Provide better errors for push on non-bare local remotes 2013-09-04 13:07:42 -07:00
Vicent Martí
e98535923b Merge pull request #1817 from libgit2/ntk/fix/backend/honor_refresh_capabilities
Of backends and refreshers...
2013-09-04 06:20:36 -07:00
Vicent Marti
74b38d199e Backport @peff's fix for duplicates in sha1_lookup 2013-09-04 13:16:57 +02:00
nulltoken
b1a6c316a6 odb: Move the auto refresh logic to the pack backend
Previously, `git_object_read()`, `git_object_read_prefix()` and
`git_object_exists()` were implementing an auto refresh logic. When the
expected object couldn't be found in any backend, a call to
`git_odb_refresh()` was triggered and the lookup was once again performed
against all backends.

This commit removes this auto-refresh logic from the odb layer and pushes
it down into the pack-backend (as it's the only one currently exposing
a `refresh()` endpoint).
2013-09-04 07:44:53 +02:00
Russell Belfer
cae5293854 Fix resolving relative windows network paths 2013-09-03 14:00:27 -07:00
Vicent Martí
6208bd499b Merge pull request #1804 from ethomson/rewrites
Minor changes for rewrites
2013-09-03 12:29:18 -07:00
Russell Belfer
37fc44ddff Merge pull request #1825 from nvloff/resolve_relative
path: properly resolve relative paths
2013-09-03 12:27:56 -07:00
Nikolai Vladimirov
6d9a6c5cec path: properly resolve relative paths 2013-09-03 20:45:53 +03:00
Vicent Martí
b595b385df Merge pull request #1814 from libgit2/is-empty-fix
Fix incorrect precedence within git_repository_is_empty()
2013-09-03 04:11:07 -07:00
Krzysztof Adamski
b1447edebc Use git__insertsort_r on Android too. 2013-09-01 18:47:56 +02:00
Linquize
d45e9480e7 oid: git_oid_shorten_add() sets GITERR_INVALID when OID set is full 2013-08-31 18:22:50 +08:00
nulltoken
9b4ed214f4 odb: Code beautification 2013-08-30 23:19:02 +02:00
nulltoken
a12e069a3e odb: Honor the non refreshing capability of a backend 2013-08-30 23:19:02 +02:00
Russell Belfer
4218183631 Treat detached HEAD as non-empty repo
This simplifies the git_repository_is_empty a bit so that a
detached HEAD is just taken to mean the repo is not empty, since
a newly initialized repo will not have a detached HEAD.
2013-08-29 10:27:01 -07:00
Vicent Martí
8b2f230cd5 repository: Make the is_empty check more explicit 2013-08-29 13:27:37 +02:00
Justin Spahr-Summers
4ab6a759f6 Fix incorrect precedence within git_repository_is_empty()
Reverts part of 9146f1e57e.
2013-08-28 22:51:57 -07:00
Russell Belfer
19b9a09209 Add stddef include for sortedcache
All use of sortedcache will need this header, so put it in the
definition of the sortedcache API.
2013-08-28 11:20:47 -07:00
Vicent Martí
dbecec37a7 Merge pull request #1805 from libgit2/threading-packed-load
Thread safety for the refdb_fs
2013-08-28 09:38:14 -07:00
Edward Thomson
17c7fbf6d2 Split rewrites, status doesn't return rewrites
Ensure that we apply splits to rewrites, even if we're not
interested in examining it closely for rename/copy detection.

In keeping with core git, status should not display rewrites,
it should simply show files as "modified".
2013-08-28 08:30:19 -05:00
Vicent Martí
1ef05e3f0e Merge pull request #1803 from libgit2/ntk/topic/even_more_lenient_remote_parsing
Even more lenient remote parsing
2013-08-28 06:05:50 -07:00