Commit Graph

5401 Commits

Author SHA1 Message Date
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
Vicent Martí
bf3ee3cf31 Merge pull request #1705 from arrbee/avoid-index-double-free
Try harder not to double free index entries
2013-07-10 10:58:58 -07:00
Vicent Martí
bf730611da Merge pull request #1717 from libgit2/arrbee/pr-1706-merged-and-cleaned
PR 1706 plus error reporting cleanups
2013-07-10 10:58:26 -07:00
Russell Belfer
33c8c6f0b8 trivial whitespace fixup 2013-07-10 10:48:32 -07:00
Russell Belfer
c2de6b1adf Bring SSH error reporting up to base standards
The SSH error checking and reporting could still be further
improved by using the libssh2 native methods to get error info,
but at least this ensures that all error codes are checked and
translated into libgit2 error messages.
2013-07-10 10:21:24 -07:00
Russell Belfer
68bc49a158 Merge branch 'ssh-cred-fix' of tiennou/libgit2
Conflicts:
	src/transports/ssh.c
2013-07-10 09:20:46 -07:00
Etienne Samson
08bf80fa2b Tab indent. 2013-07-10 09:42:28 +02:00
Etienne Samson
367c1903e9 Add some missing error messages. 2013-07-10 09:33:14 +02:00
Vicent Martí
b8cd7aa9f6 Merge pull request #1704 from arrbee/kill-status-index-then-workdir
Remove GIT_STATUS_SHOW_INDEX_THEN_WORKDIR option
2013-07-09 17:20:55 -07:00
Vicent Martí
77fa06f3d9 Merge pull request #1695 from arrbee/fix-1695
API should not be ifdeffed
2013-07-09 17:20:36 -07:00
Vicent Martí
550cd2d776 Merge pull request #1716 from arrbee/fix-config-get-multivar
Fix git_config_get_multivar with interleaved missing entries
2013-07-09 16:54:34 -07:00
Russell Belfer
e4fda954d6 A little git_config_get_multivar code cleanup 2013-07-09 16:46:18 -07:00
Russell Belfer
7b5c0d1846 Add more tests for git_config_get_multivar
The old tests didn't try failing lookups or lookups across
multiple config files with some having the pattern and some
not having it.
2013-07-09 16:45:23 -07:00
J. David Ibáñez
07fba63e9e Fix return value in git_config_get_multivar
If there is not an error, the return value was always the return value
of the last call to file->get_multivar

With this commit GIT_ENOTFOUND is only returned if all the calls to
filge-get_multivar return GIT_ENOTFOUND.
2013-07-09 16:23:46 -07:00
Russell Belfer
290e147985 Add GIT_CAP_SSH if library was built with SSH
This also adds a test that actually calls git_libgit2_capabilities
and git_libgit2_version.
2013-07-09 16:17:41 -07:00
Russell Belfer
a4456929a8 Make credential clearing consistent
This makes all of the credential objects use the same pattern to
clear the contents and call git__memzero when done.  Much of this
information is probably not sensitive, but it also seems better
to just clear consistently.
2013-07-09 16:16:24 -07:00
Russell Belfer
03d9b930ee Indent with tabs 2013-07-09 14:45:58 -07:00
Russell Belfer
3eae9467e5 Merge pull request #1710 from arrbee/fix-1710
Null byte in hunk header
2013-07-09 14:24:57 -07:00