Commit Graph

2112 Commits

Author SHA1 Message Date
Russell Belfer
65b09b1ded Implement diff lists and formatters
This reworks the diff API to separate the steps of producing
a diff descriptions from formatting the diff.  This will allow
us to share diff output code with the various diff creation
scenarios and will allow us to implement rename detection as
an optional pass that can be run on a diff list.
2012-03-02 15:49:28 -08:00
Russell Belfer
cd33323b72 Initial implementation of git_diff_blob
This gets the basic plumbing in place for git_diff_blob.
There is a known issue where additional parameters like
the number of lines of context to display on the diff
are not working correctly (which leads one of the new
unit tests to fail).
2012-03-02 15:49:28 -08:00
Russell Belfer
8b75f7f3ea Eliminate xdiff compiler warnings
This cleans up the various GCC compiler warnings with the
xdiff code that was copied in.
2012-03-02 15:49:28 -08:00
Russell Belfer
2705576bfa Simplify GIT_UNUSED macros
Since casting to void works to eliminate errors with unused
parameters on all platforms, avoid the various special cases.
Over time, it will make sense to eliminate the GIT_UNUSED
macro completely and just have GIT_UNUSED_ARG.
2012-03-02 15:49:28 -08:00
Russell Belfer
3a5ad90a0d Import xdiff library from git
This is the initial import of the xdiff code (LGPL) from
core git as of rev f349b562086e2b7595d8a977d2734ab2ef9e71ef
2012-03-02 15:49:28 -08:00
Russell Belfer
7e3fc62310 Add test for possible attr bug
This is a test that should replicate an issue that Peff
is setting with git attributes.  But the test doesn't fail.
2012-03-02 15:49:28 -08:00
Vicent Martí
e3d55b2add Merge pull request #575 from libgit2/filters
Filters, yo
2012-03-02 15:44:15 -08:00
Russell Belfer
ce49c7a8a9 Add filter tests and fix some bugs
This adds some initial unit tests for file filtering and fixes
some simple bugs in filter application.
2012-03-02 15:09:40 -08:00
Vicent Martí
d377fe80b1 attr: Add missing header to test suite 2012-03-02 22:12:46 +01:00
Vicent Martí
97da3eaec8 config: Add missing file 2012-03-02 21:12:00 +01:00
Vicent Martí
f2c25d1893 config: Implement a proper cvar cache 2012-03-02 20:08:00 +01:00
Vicent Martí
c63793ee81 attr: Change the attribute check macros
The point of having `GIT_ATTR_TRUE` and `GIT_ATTR_FALSE` macros is to be
able to change the way that true and false values are stored inside of
the returned gitattributes value pointer.

However, if these macros are implemented as a simple rename for the
`git_attr__true` pointer, they will always be used with the `==`
operator, and hence we cannot really change the implementation to any
other way that doesn't imply using special pointer values and comparing
them!

We need to do the same thing that core Git does, which is using a
function macro. With `GIT_ATTR_TRUE(attr)`, we can change
internally the way that these values are stored to anything we want.

This commit does that, and rewrites a large chunk of the attributes test
suite to remove duplicated code for expected attributes, and to
properly test the function macro behavior instead of comparing
pointers.
2012-03-02 03:51:45 +01:00
Vicent Martí
47a899ffed filter: Beautiful refactoring
Comments soothe my soul.
2012-03-01 21:19:51 +01:00
Vicent Martí
788430c8e3 filter: Properly cache filter settings 2012-03-01 05:06:47 +01:00
Vicent Martí
c5266ebac5 filter: Precache the filter config options on load 2012-03-01 01:16:50 +01:00
Vicent Martí
c5e944820a config: Refactor & add git_config_get_mapped
Sane API for real-world usage.
2012-03-01 00:52:21 +01:00
Vicent Martí
27950fa3f4 filter: Add write-to CRLF filter 2012-02-29 01:35:47 +01:00
Vicent Martí
450b40cab3 filter: Load attributes for file 2012-02-28 01:13:32 +01:00
Vicent Martí
17b3d9b92b Merge pull request #576 from carlosmn/revwalk
Friendlier revision walking
2012-02-27 14:03:20 -08:00
Carlos Martín Nieto
a4a910dd9c Simple test for pushing HEAD and hiding a branch 2012-02-27 22:46:45 +01:00
Carlos Martín Nieto
f7367993cb revwalk: add convenience function to push/hide HEAD
It's not unusual to want the walker to act on HEAD, so add a
convencience function for the case that the user doesn't already have
a resolved HEAD reference.
2012-02-27 22:26:37 +01:00
Carlos Martín Nieto
f0fa1c1a73 Add revwalk glob test 2012-02-27 22:07:20 +01:00
Carlos Martín Nieto
155aca2da7 revwalk: introduce pushing and hiding by glob
git_revwalk_{push,hide}_glob() lets you push the OIDs of references
that match the specified glob. This is the basics for what git.git
does with the rev-list options --branches, --tags, --remotes and
--glob.
2012-02-27 22:00:27 +01:00
Carlos Martín Nieto
8f7be6ca8a Move revwalk test to clar 2012-02-27 21:38:22 +01:00
Vicent Martí
eb8f90e523 buffer: Null terminate on rtrim 2012-02-27 17:22:51 +01:00
Vicent Martí
44b1ff4c12 filter: Apply filters before writing a file to the ODB
Initial implementation. The relevant code is in `blob.c`: the blob write
function has been split into smaller functions.

	- Directly write a file to the ODB in streaming mode

	- Directly write a symlink to the ODB in direct mode

	- Apply a filter, and write a file to the ODB in direct mode

When trying to write a file, we first call `git_filter__load_for_file`,
which populates a filters array with the required filters based on the
filename.

If no filters are resolved to the filename, we can write to the ODB in
streaming mode straight from disk. Otherwise, we load the whole file in
memory and use double-buffering to apply the filter chain. We finish
by writing the file as a whole to the ODB.
2012-02-27 05:30:07 +01:00
Vicent Martí
13224ea4aa buffer: Unify git_fbuffer and git_buf
This makes so much sense that I can't believe it hasn't been done
before. Kill the old `git_fbuffer` and read files straight into
`git_buf` objects.

Also: In order to fully support 4GB files in 32-bit systems, the
`git_buf` implementation has been changed from using `ssize_t` for
storage and storing negative values on allocation failure, to using
`size_t` and changing the buffer pointer to a magical pointer on
allocation failure.

Hopefully this won't break anything.
2012-02-27 05:30:07 +01:00
Vicent Martí
e07c2d225d Merge pull request #574 from carlosmn/remotes
Add git_remote_list()
2012-02-26 10:45:23 -08:00
Carlos Martín Nieto
8171998f8d Add git_remote_list()
Loops through the configuration and generates a list of configured
remotes.
2012-02-26 19:15:36 +01:00
Carlos Martín Nieto
6b63589e35 config: add more comprehensive multivar tests 2012-02-25 19:01:02 +01:00
Carlos Martín Nieto
0a43d7cb19 config: correctly deal with setting a multivar with regex where there are no matches
We used to erroneously consider "^$" as a special case for appending a
value to a multivar. This was a misunderstanding and we should always
append a value if there are no existing values that match.

While we're in the area, replace all the variables in-memory in one
swoop and then replace them on disk so as to avoid matching a value
we've just introduced.
2012-02-25 19:00:06 +01:00
Carlos Martín Nieto
9554cd514c A remote exists with an URL alone
We used to consider it an error if a remote didn't have at least a
fetch refspec. This was too much checking, as a remote doesn't in fact
need to have anything other than an URL configured to be considered
a remote.
2012-02-24 12:14:26 +01:00
Paul Betts
1db9d2c3bb Ensure that commits don't fail if committing content that already exists
Making a commit that results in a blob that already exists in the ODB (i.e.
committing something, then making a revert commit) will result in us trying
to p_rename -> MoveFileExW a temp file into the existing ODB entry. Despite
the MOVEFILE_REPLACE_EXISTING flag is passed in, Win32 does not care and
fails it with STATUS_ACCESS_DENIED.

To fix this, we p_unlink the ODB entry before attempting to rename it. This
call will typically fail, but we don't care, we'll let the p_rename fail if
the file actually does exist and we couldn't delete it for some reason (ACLs,
etc).
2012-02-23 17:11:20 -08:00
Vicent Martí
34ab819ef9 Merge pull request #573 from schu/tests-notes-fix
tests-clar/notes: init oid before using
2012-02-23 14:45:40 -08:00
schu
aa4254d92e tests-clar/notes: init oid before using
Reported-by: Carlos Martín Nieto <carlos@cmartin.tk>
Signed-off-by: schu <schu-github@schulog.org>
2012-02-23 23:38:48 +01:00
Carlos Martín Nieto
82ccb87ef6 tree: break out on write error
If write_tree() returs an error, we used to set the error message and
continued looping. Exit the loop so we return the error.
2012-02-23 23:00:45 +01:00
Russell Belfer
f01fa26690 Fix workdir iterator unit tests
This test is fragile if you leave extra files in the test
data directory, such as a foo.c~ file from editing with
Emacs.  Who would do such a thing?
2012-02-23 11:17:48 -08:00
Russell Belfer
290f240ee0 Fix readdir usage across platforms
This fixes the missing readdir_r from win32 and fixes other
platforms to always use the reentrant readdir_r form for reading
directory contents.
2012-02-23 11:16:47 -08:00
Russell Belfer
1ec1de6d43 Fix warnings about type conversion on win32 2012-02-23 11:15:45 -08:00
Vicent Martí
df16fbcf36 Merge pull request #572 from schu/fix-warning-uninitialized
Fix -Wuninitialized warning
2012-02-23 08:18:54 -08:00
schu
0126954007 Fix -Wuninitialized warning
Signed-off-by: schu <schu-github@schulog.org>
2012-02-23 16:51:07 +01:00
Vicent Martí
36d72a5125 Merge pull request #570 from arrbee/uniform-iterators
Uniform iterators for trees, index, and workdir
2012-02-22 16:06:33 -08:00
Russell Belfer
0534641dfe Fix iterators based on pull request feedback
This update addresses all of the feedback in pull request #570.

The biggest change was to create actual linked list stacks for
storing the tree and workdir iterator state.  This cleaned up
the code a ton.  Additionally, all of the static functions had
their 'git_' prefix removed, and a lot of other unnecessary
changes were removed from the original patch.
2012-02-22 15:15:35 -08:00
Russell Belfer
da337c8064 Iterator improvements from diff implementation
This makes two changes to iterator behavior: first, advance
can optionally do the work of returning the new current value.
This is such a common pattern that it really cleans up usage.

Second, for workdir iterators, this removes automatically
iterating into directories.  That seemed like a good idea,
but when an entirely new directory hierarchy is introduced
into the workdir, there is no reason to iterate into it if
there are no corresponding entries in the tree/index that it
is being compared to.

This second change actually wasn't a lot of code because not
descending into directories was already the behavior for
ignored directories.  This just extends that to all directories.
2012-02-22 11:22:33 -08:00
Vicent Martí
8d36b253e2 Merge pull request #565 from carlosmn/multimap
Add config multivar support
2012-02-22 11:12:20 -08:00
Vicent Martí
20ed8983ea Merge pull request #571 from saurik/development
Export parse_tag_buffer as git_tag__parse_buffer.
2012-02-22 11:09:48 -08:00
Jay Freeman (saurik)
b60deb0235 Export parse_tag_buffer as git_tag__parse_buffer. 2012-02-22 04:45:30 +00:00
Russell Belfer
b6c93aef42 Uniform iterators for trees, index, and workdir
This create a new git_iterator type of object that provides a
uniform interface for iterating over the index, an arbitrary
tree, or the working directory of a repository.

As part of this, git ignore support was extended to support
push and pop of directory-based ignore files as the working
directory is being traversed (so the array of ignores does
not have to be recreated at each directory during traveral).

There are a number of other small utility functions in buffer,
path, vector, and fileops that are included in this patch
that made the iterator implementation cleaner.
2012-02-21 14:46:24 -08:00
Carlos Martín Nieto
9c94a356cc Fix check for writing remote's fetch and push configurations
Fix copy-paste error
2012-02-21 12:15:23 +01:00
Vicent Martí
481f5e2721 Merge pull request #568 from carlosmn/remotes
Remotes improvements
2012-02-20 11:35:08 -08:00