Commit Graph

5117 Commits

Author SHA1 Message Date
Rémi Duraffort
050af8bbe0 pack: fix memory leak in error path 2013-07-15 16:29:13 +02:00
Rémi Duraffort
8d6ef4bf78 index: fix potential memory leaks 2013-07-15 16:29:09 +02:00
Rémi Duraffort
9146f1e57e repository: clarify assignment and test order 2013-07-15 16:29:00 +02:00
Russell Belfer
351733128c Merge pull request #1727 from alindeman/lookup-object-doc-fix
Fixes return type documentation
2013-07-14 15:16:08 -07:00
Andy Lindeman
960431c380 Fixes return type documentation 2013-07-14 18:08:54 -04:00
Vicent Martí
1662158cf9 Merge pull request #1725 from libgit2/ntk/fix/leaks
Plug some memory leaks
2013-07-13 06:18:24 -07:00
nulltoken
d6cb13d743 tests: Fix memory leak 2013-07-13 14:14:43 +02:00
nulltoken
b3a559ddce submodule: Fix memory leaks 2013-07-13 14:14:40 +02:00
Vicent Martí
3a025b97ff Merge pull request #1724 from ethomson/cmake_vs
header files show up in vs and xcode
2013-07-12 17:03:57 -07:00
Edward Thomson
cdacd3d931 header files show up in vs 2013-07-12 16:53:00 -05:00
Vicent Martí
ed0be48b93 Merge pull request #1721 from ethomson/config_paths
preload configuration paths
2013-07-11 15:36:03 -07:00
Edward Thomson
0a1c8f55b3 preload configuration paths 2013-07-11 17:17:53 -05:00
Vicent Martí
f2de67d589 Merge pull request #1719 from libgit2/arrbee/threading-primitives
Update git__swap threading primitive
2013-07-11 11:27:57 -07:00
Russell Belfer
584f2d3013 Fix warnings on Win64 2013-07-11 11:04:42 -07:00
Russell Belfer
814de0bcab Update git__swap thread helper
This makes git__swap use the __sync_lock_test_and_set primitive
with GCC and the InterlockedExchangePointer primitive with MSVC.
Previously is used compare_and_swap in a way that was probably
unintuitive for most thinking (i.e. it could fail to swap in the
value if another thread raced in).  Now it will always succeed
and the last thread to run in a race will win instead of the
first thread.

This also fixes up a little confusion between volatile void **
and void * volatile * that came up with the Win32 compiler.
2013-07-11 11:00:41 -07:00
Russell Belfer
d70ce9bd7a Clarify docs for git_status_file 2013-07-10 15:38:57 -07:00
Vicent Martí
bd679796a5 Merge pull request #1685 from arrbee/submodule-status-fixes
Improve submodules status data caching and compatibility
2013-07-10 13:15:28 -07:00
Russell Belfer
125655fe3f Untracked directories with .git should be ignored
This restores a behavior that was accidentally lost during some
diff refactoring where an untracked directory that contains a .git
item should be treated as IGNORED, not as UNTRACKED.  The submodule
code already detects this, but the diff code was not handling the
scenario right.

This also updates a number of existing tests that were actually
exercising the behavior but did not have the right expectations in
place.  It actually makes the new
`test_diff_submodules__diff_ignore_options` test feel much better
because the "not-a-submodule" entries are now ignored instead of
showing up as untracked items.

Fixes #1697
2013-07-10 12:15:03 -07:00
Russell Belfer
9564229af4 Add tests for diff.ignoreSubmdules config 2013-07-10 12:15:03 -07:00
Russell Belfer
b8df28a5da Clean up left over alloc change 2013-07-10 12:15:03 -07:00
Russell Belfer
f9775a37aa Add ignore_submodules to diff options
This adds correct support for an equivalent to --ignore-submodules
in diff, where an actual ignore value can be passed to diff to
override the per submodule settings in the configuration.

This required tweaking the constants for ignore values so that
zero would not be used and could represent an unset option to the
diff.  This was an opportunity to move the submodule values into
include/git2/types.h and to rename the poorly named DEFAULT values
for ignore and update constants to RESET instead.

Now the GIT_DIFF_IGNORE_SUBMODULES flag is exactly the same as
setting the ignore_submodules option to GIT_SUBMODULE_IGNORE_ALL
(which is actually a minor change from the old behavior in that
submodules will now be treated as UNMODIFIED deltas instead of
being left out totally - if you set GIT_DIFF_INCLUDE_UNMODIFIED).

This includes tests for the various new settings.
2013-07-10 12:15:03 -07:00
Russell Belfer
2e3e273e33 Update diff to new internal submodule status API
Submodules now expose an internal status API that allows diff to
get back the OID values from the submodule very easily and also
to avoiding caching issues and to override the ignore setting for
the submodule.
2013-07-10 12:14:13 -07:00
Russell Belfer
1aad6137d2 Submodule status improvements
This fixes the way that submodule status is checked to bypass just
about all of the caching in the submodule object.  Based on the
ignore value, it will try to do the minimum work necessary to find
the current status of the submodule - but it will actually go to
disk to get all of the current values.

This also removes the custom refcounting stuff in favor of the
common git_refcount style.  Right now, it is still for internal
purposes only, but it should make it easier to add true submodule
refcounting in the future with a public git_submodule_free call
that will allow bindings not to worry about the submodule object
getting freed from underneath them.
2013-07-10 12:14:13 -07:00
Russell Belfer
3fe046cfdb Add BARE option to git_repository_open_ext
This adds a BARE option to git_repository_open_ext which allows
a fast open path that still knows how to read gitlinks and to
search for the actual .git directory from a subdirectory.

`git_repository_open_bare` is still simpler and faster, but having
a gitlink aware fast open is very useful for submodules where we
want to quickly be able to peek at the HEAD and index data without
doing any other meaningful repo operations.
2013-07-10 12:14:13 -07:00
Russell Belfer
302a04b09c Add accessors for refcount value 2013-07-10 12:14:13 -07:00
Russell Belfer
e807860fa9 Add timestamp check to submodule status
This is probably not the final form of this change, but this is
a preliminary version of checking a timestamp to see if the cached
working directory HEAD OID matches the current.  Right now, this
uses the timestamp on the index and is, like most of our timestamp
checking, subject to having only second accuracy.
2013-07-10 12:14:13 -07:00
Russell Belfer
41f1f9d732 Add API to get path to index file 2013-07-10 12:14:13 -07:00
Russell Belfer
4535f04409 More diff submodule tests for cache issues
The submodules code caches data about submodules in a way that
can cause problems.  This adds some tests that try making various
modifications to the state of a submodule to see where we can
catch out problems in the submodule caching.

Right now, I've put in an extra git_submodule_reload_all so that
the test will pass, but with that commented out, the test fails.
I'm working on fixing the broken version of the test at which
point I'll commit the fix and delete the extra reload that makes
the test pass.
2013-07-10 12:14:12 -07:00
Russell Belfer
3e7d7100e2 Fix diff test helper to show parent file/line 2013-07-10 12:14:12 -07:00
Russell Belfer
49621a34af Fix memory leak in test 2013-07-10 12:14:12 -07:00
Russell Belfer
12f8fe0054 More improvements to submodule diff tests
This controls for the diff.mnemonicprefix setting so that can't
break the tests.  Also, this expands one test to emulate an
ObjectiveGit test more closely.
2013-07-10 12:14:12 -07:00
Russell Belfer
0105b55e8f Add another submodule test of dirty wd 2013-07-10 12:14:12 -07:00
Vicent Marti
c0e529f379 Merge branch 'arrbee/examples-log' into development 2013-07-10 21:06:53 +02:00
Vicent Marti
406dd556e2 bitvec: Simplify the bit vector code 2013-07-10 21:05:47 +02:00
Russell Belfer
2b672d5b64 Add git_pathspec_match_diff API
This adds an additional pathspec API that will match a pathspec
against a diff object.  This is convenient if you want to handle
renames (so you need the whole diff and can't use the pathspec
constraint built into the diff API) but still want to tell if the
diff had any files that matched the pathspec.

When the pathspec is matched against a diff, instead of keeping
a list of filenames that matched, instead the API keeps the list
of git_diff_deltas that matched and they can be retrieved via a
new API git_pathspec_match_list_diff_entry.

There are a couple of other minor API extensions here that were
mostly for the sake of convenience and to reduce dependencies
on knowing the internal data structure between files inside the
library.
2013-07-10 20:50:33 +02:00
Russell Belfer
6fc5a58197 Basic bit vector
This is a simple bit vector object that is not resizable after
the initial allocation but can be of arbitrary size.  It will
keep the bti vector entirely on the stack for vectors 64 bits
or less, and will allocate the vector on the heap for larger
sizes.  The API is uniform regardless of storage location.

This is very basic right now and all the APIs are inline functions,
but it is useful for storing an array of boolean values.
2013-07-10 20:50:33 +02:00
Russell Belfer
3e96ecf219 Improve include/git2/pathspec.h docs 2013-07-10 20:50:33 +02:00
Russell Belfer
9abc78ae61 Convert commit->parent_ids to git_array_t
This converts the array of parent SHAs from a git_vector where
each SHA has to be separately allocated to a git_array_t where
all the SHAs can be kept in one block.  Since the two collections
have almost identical APIs, there isn't much involved in making
the change.  I did add an API to git_array_t so that it could be
allocated at a precise initial size.
2013-07-10 20:50:32 +02:00
Russell Belfer
bc6f0839eb Add a bunch more features to log example 2013-07-10 20:50:32 +02:00
Russell Belfer
a8b5f116bc Fix example/log.c pathspec handling of merges
This fixes the way the example log program decides if a merge
commit should be shown when a pathspec is given.  Also makes it
easier to use the pathspec API to just check "does a tree match
anything in the pathspec" without allocating a match list.
2013-07-10 20:50:32 +02:00
Russell Belfer
733c4f3aca more examples/log.c bug fixing 2013-07-10 20:50:32 +02:00
Russell Belfer
5a169711fa fix bug with order args and no revision 2013-07-10 20:50:32 +02:00
Russell Belfer
2b3bd8ecd8 Fix example/log.c minor diffs with git log 2013-07-10 20:50:32 +02:00
Russell Belfer
f44c4fa108 Add basic commit formatting to log output 2013-07-10 20:50:32 +02:00
Russell Belfer
f094f9052f Add raw header access to commit API 2013-07-10 20:50:32 +02:00
Russell Belfer
8ba0ff6972 rev-parse example 2013-07-10 20:50:32 +02:00
Russell Belfer
d0628e2fee More progress on log example 2013-07-10 20:50:32 +02:00
Russell Belfer
0d44d3dc84 Extending log example code
This adds more command line processing to the example version of
log.  In particular, this adds the funky command line processing
that allows an arbitrary series of revisions followed by an
arbitrary number of paths and/or glob patterns.

The actual logging part still isn't implemented.
2013-07-10 20:50:32 +02:00
Russell Belfer
d2ce27dd49 Add public API for pathspec matching
This adds a new public API for compiling pathspecs and matching
them against the working directory, the index, or a tree from the
repository.  This also reworks the pathspec internals to allow the
sharing of code between the existing internal usage of pathspec
matching and the new external API.

While this is working and the new API is ready for discussion, I
think there is still an incorrect behavior in which patterns are
always matched against the full path of an entry without taking
the subdirectories into account (so "s*" will match "subdir/file"
even though it wouldn't with core Git).  Further enhancements are
coming, but this was a good place to take a functional snapshot.
2013-07-10 20:50:31 +02:00
Russell Belfer
d39fff3648 Basic framework for log command 2013-07-10 20:50:31 +02:00