|
0f3def71
|
2012-11-09T11:19:46
|
|
Fix various cross-platform build issues
This fixes a number of warnings and problems with cross-platform
builds. Among other things, it's not safe to name a member of a
structure "strcmp" because that may be #defined.
|
|
55cbd05b
|
2012-11-08T16:56:34
|
|
Some diff refactorings to help code reuse
There are some diff functions that are useful in a rewritten
checkout and this lays some groundwork for that. This contains
three main things:
1. Share the function diff uses to calculate the OID for a file
in the working directory (now named `git_diff__oid_for_file`
2. Add a `git_diff__paired_foreach` function to iterator over
two diff lists concurrently. Convert status to use it.
3. Move all the string/prefix/index entry comparisons into
function pointers inside the `git_diff_list` object so they
can be switched between case sensitive and insensitive
versions. This makes them easier to reuse in various
functions without replicating logic. As part of this, move
a couple of index functions out of diff.c and into index.c.
|
|
cb7180a6
|
2012-10-25T11:48:39
|
|
Add git_diff_patch_print
This adds a `git_diff_patch_print()` API which is more like the
existing API to "print" a patch from an entire `git_diff_list`
but operates on a single `git_diff_patch` object.
Also, it rewrites the `git_diff_patch_to_str()` API to use that
function (making it very small).
|
|
3943dc78
|
2012-10-25T11:12:56
|
|
Check errors while generating diff patch string
|
|
93cf7bb8
|
2012-10-24T20:56:32
|
|
Add git_diff_patch_to_str API
This adds an API to generate a complete single-file patch text
from a git_diff_patch object.
|
|
0d64bef9
|
2012-10-05T15:56:57
|
|
Add complex checkout test and then fix checkout
This started as a complex new test for checkout going through the
"typechanges" test repository, but that revealed numerous issues
with checkout, including:
* complete failure with submodules
* failure to create blobs with exec bits
* problems when replacing a tree with a blob because the tree
"example/" sorts after the blob "example" so the delete was
being processed after the single file blob was created
This fixes most of those problems and includes a number of other
minor changes that made it easier to do that, including improving
the TYPECHANGE support in diff/status, etc.
|
|
5d1308f2
|
2012-10-08T15:19:00
|
|
Add test for diffs with submodules and bug fixes
The adds a test for the submodule diff capabilities and then
fixes a few bugs with how the output is generated. It improves
the accuracy of OIDs in the diff delta object and makes the
submodule output more closely mirror the OIDs that will be used
by core git.
|
|
dfbff793
|
2012-10-08T15:14:12
|
|
Fix a few diff bugs with directory content
There are a few cases where diff should leave directories in
the diff list if we want to match core git, such as when the
directory contains a .git dir. That feature was lost when I
introduced some of the new submodule handling.
This restores that and then fixes a couple of related to diff
output that are triggered by having diffs with directories in
them.
Also, this adds a new flag that can be passed to diff if you
want diff output to actually include the file content of any
untracked files.
|
|
1686641f
|
2012-10-05T13:03:22
|
|
Extract submodule logic out of diff_output.c:get_workdir_content
|
|
7e57d250
|
2012-09-18T23:43:23
|
|
Diff: teach get_workdir_content to show a submodule as text
1. teach diff.c:maybe_modified to query git_submodule_status for the
modification state of a submodule. According to the
git_submodule_status docs, it will filter for to-ignore states
already.
2. teach diff_output.c:get_workdir_content to check the submodule status
again and create a line like:
Subproject commit <SHA-1>\n
or
Subproject comimt <SHA-1>-dirty\n
like git.git does.
|
|
9ce44f1a
|
2012-09-18T22:35:09
|
|
Diff: teach get_blob_content to show a submodule as text
diff_output.c:get_blob_content used to try to read the submodule commit
as a blob in the superproject's odb. Of course it cannot find it and
errors out with GIT_ENOTFOUND, implcitly terminating the whole diff
output.
This patch teaches it to create a text that describes the submodule
instead. The text looks like:
Subproject commit <SHA1>\n
which is what git.git does, too.
|
|
1a5cd26b
|
2012-10-05T13:02:35
|
|
Fix minor whitespace issue
|
|
cc5bf359
|
2012-09-28T09:08:09
|
|
Clean up Win64 warnings
|
|
bae957b9
|
2012-09-25T16:31:46
|
|
Add const to all shared pointers in diff API
There are a lot of places where the diff API gives the user access
to internal data structures and many of these were being exposed
through non-const pointers. This replaces them all with const
pointers for any object that the user can access but is still
owned internally to the git_diff_list or git_diff_patch objects.
This will probably break some bindings... Sorry!
|
|
64286308
|
2012-09-25T10:48:50
|
|
Fix bugs in new diff patch code
This fixes all the bugs in the new diff patch code. The only
really interesting one is that when we merge two diffs, we now
have to actually exclude diff delta records that are not supposed
to be tracked, as opposed to before where they could be included
because they would be skipped silently by `git_diff_foreach()`.
Other than that, there are just minor errors.
|
|
5f69a31f
|
2012-09-24T20:52:34
|
|
Initial implementation of new diff patch API
Replacing the `git_iterator` object, this creates a simple API
for accessing the "patch" for any file pair in a diff list and
then gives indexed access to the hunks in the patch and the lines
in the hunk. This is the initial implementation of this revised
API - it is still broken, but at least builds cleanly.
|
|
9ac8b113
|
2012-09-20T14:06:49
|
|
Fix MSVC amd64 compilation warnings
|
|
12b6af17
|
2012-09-13T14:15:07
|
|
Forgot to reset hunk & line between files
The last change tweaked the way we use the hunk_curr pointer
during iteration, but failed to reset the value back to NULL
when switching files.
|
|
49d34c1c
|
2012-09-13T13:17:38
|
|
Fix problems in diff iterator record chaining
There is a bug in building the linked list of line records in the
diff iterator and also an off by one element error in the hunk
counts. This fixes both of these, adds some test data with more
complex sets of hunk and line diffs to exercise this code better.
|
|
1f35e89d
|
2012-09-11T12:03:33
|
|
Fix diff binary file detection
In the process of adding tests for the max file size threshold
(which treats files over a certain size as binary) there seem to
be a number of problems in the new code with detecting binaries.
This should fix those up, as well as add a test for the file
size threshold stuff.
Also, this un-deprecates `GIT_DIFF_LINE_ADD_EOFNL`, since I
finally found a legitimate situation where it would be returned.
|
|
c6ac28fd
|
2012-09-10T12:24:05
|
|
Reorg internal odb read header and object lookup
Often `git_odb_read_header` will "fail" and have to read the
entire object into memory instead of just the header. When this
happens, the object is loaded and then disposed of immediately,
which makes it difficult to efficiently use the header information
to decide if the object should be loaded (since attempting to do
so will often result in loading the object twice).
This commit takes the existing code and reorganizes it to have
two new functions:
- `git_odb__read_header_or_object` which acts just like the old
read header function except that it returns the object, too, if
it was forced to load the whole thing. It then becomes the
callers responsibility to free the `git_odb_object`.
- `git_object__from_odb_object` which was extracted from the old
`git_object_lookup` and creates a subclass of `git_object` from
an existing `git_odb_object` (separating the ODB lookup from the
`git_object` creation). This allows you to use the first header
reading function efficiently without instantiating the
`git_odb_object` twice.
There is no net change to the behavior of any of the existing
functions, but this allows internal code to tap into the ODB
lookup and object creation to be more efficient.
|
|
e597b189
|
2012-09-10T11:49:12
|
|
Move diff max_size to public API
This commit adds a max_size value in the public `git_diff_options`
structure so that the user can automatically flag blobs over a
certain size as binary regardless of other properties.
Also, and perhaps more importantly, this moves binary detection
to be as early as possible in the diff traversal inner loop and
makes sure that we stop loading objects as soon as we decide that
they are binary.
|
|
b36effa2
|
2012-09-10T09:59:14
|
|
Replace git_diff_iterator_num_files with progress
The `git_diff_iterator_num_files` API was problematic, since we
don't actually know the exact number of files to be iterated over
until we load those files into memory. This replaces it with a
new `git_diff_iterator_progress` API that goes from 0 to 1, and
moves and renamed the old API for the internal places that can
tolerate a max value instead of an exact value.
|
|
3a3deea8
|
2012-09-06T15:45:50
|
|
Clean up blob diff path
Previously when diffing blobs, the diff code just ran with a NULL
repository object. Of course, that's not necessary and the test
for a NULL repo was confusing. This makes the blob diff run with
the repo that contains the blobs and clarifies the test that it
is possible to be diffing data where the path is unknown.
|
|
60b9d3fc
|
2012-09-05T15:00:40
|
|
Implement filters for status/diff blobs
This adds support to diff and status for running filters (a la crlf)
on blobs in the workdir before computing SHAs and before generating
text diffs. This ended up being a bit more code change than I had
thought since I had to reorganize some of the diff logic to minimize
peak memory use when filtering blobs in a diff.
This also adds a cap on the maximum size of data that will be loaded
to diff. I set it at 512Mb which should match core git. Right now
it is a #define in src/diff.h but it could be moved into the public
API if desired.
|
|
01ae1909
|
2012-09-06T10:13:38
|
|
diff: Cleanup documentation and printf compat
|
|
510f1bac
|
2012-08-30T16:39:05
|
|
Fix comments and a minor bug
This adds better header comments and also fixes a bug in one of
simple APIs that tells the number of lines in the current hunk.
|
|
f335ecd6
|
2012-08-30T14:24:16
|
|
Diff iterators
This refactors the diff output code so that an iterator object
can be used to traverse and generate the diffs, instead of just
the `foreach()` style with callbacks. The code has been rearranged
so that the two styles can still share most functions.
This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses
that as a common error code for marking the end of iteration when
using a iterator style of object.
|
|
b97c169e
|
2012-09-04T10:01:18
|
|
Fix MSVC compilation warnings
|
|
5f4a61ae
|
2012-08-09T19:43:25
|
|
Working implementation of git_submodule_status
This is a big redesign of the git_submodule_status API and the
implementation of the redesigned API. It also fixes a number of
bugs that I found in other parts of the submodule API while
writing the tests for the status part.
This also fixes a couple of bugs in the iterators that had not
been noticed before - one with iterating when there is a gitlink
(i.e. separate-work-dir) and one where I was treating anything
even vaguely submodule-like as a submodule, more aggressively
than core git does.
|
|
5fdc41e7
|
2012-08-22T13:57:57
|
|
Minor bug fixes in diff code
In looking at PR #878, I found a few small bugs in the diff code,
mostly related to work that can be avoided when processing tree-
to-tree diffs that was always being carried out. This commit has
some small fixes in it.
|
|
c07d9c95
|
2012-08-09T15:33:04
|
|
oid: Explicitly include `oid.h` for the inlined CMP
|
|
5dca2010
|
2012-08-03T17:08:01
|
|
Update iterators for consistency across library
This updates all the `foreach()` type functions across the library
that take callbacks from the user to have a consistent behavior.
The rules are:
* A callback terminates the loop by returning any non-zero value
* Once the callback returns non-zero, it will not be called again
(i.e. the loop stops all iteration regardless of state)
* If the callback returns non-zero, the parent fn returns GIT_EUSER
* Although the parent returns GIT_EUSER, no error will be set in
the library and `giterr_last()` will return NULL if called.
This commit makes those changes across the library and adds tests
for most of the iteration APIs to make sure that they follow the
above rules.
|
|
29f9186d
|
2012-07-02T11:18:01
|
|
diff: make inter-hunk-context default value git-compliant
Default in git core is 0, not 3
|
|
145e696b
|
2012-06-08T11:56:24
|
|
Minor fixes, cleanups, and clarifications
There are three actual changes in this commit:
1. When the trailing newline of a file is removed in a diff, the
change will now be reported with `GIT_DIFF_LINE_DEL_EOFNL` passed
to the callback. Previously, the `ADD_EOFNL` constant was given
which was just an error in my understanding of when the various
circumstances arose. `GIT_DIFF_LINE_ADD_EOFNL` is deprecated and
should never be generated. A new newline is simply an `ADD`.
2. Rewrote the `diff_delta__merge_like_cgit` function that contains
the core logic of the `git_diff_merge` implementation. The new
version doesn't actually have significantly different behavior,
but the logic should be much more obvious, I think.
3. Fixed a bug in `git_diff_merge` where it freed a string pool
while some of the string data was still in use. This led to
`git_diff_print_patch` accessing memory that had been freed.
The rest of this commit contains improved documentation in `diff.h`
to make the behavior and the equivalencies with core git clearer,
and a bunch of new tests to cover the various cases, oh and a minor
simplification of `examples/diff.c`.
|
|
0abd7244
|
2012-06-04T16:17:41
|
|
Fix filemode comparison in diffs
File modes were both not being ignored properly on platforms
where they should be ignored, nor be diffed consistently on
platforms where they are supported.
This change adds a number of diff and status filemode change
tests. This also makes sure that filemode-only changes are
included in the diff output when they occur and that filemode
changes are ignored successfully when core.filemode is false.
There is no code that automatically toggles core.filemode
based on the capabilities of the current platform, so the user
still needs to be careful in their .git/config file.
|
|
3f035860
|
2012-06-07T22:43:03
|
|
misc: Fix warnings from PVS Studio trial
|
|
2ab9dcbd
|
2012-05-27T16:47:56
|
|
Fix checking for the presence of a flag
|
|
29e948de
|
2012-05-10T10:38:10
|
|
global: Change parameter ordering in API
Consistency is good.
|
|
b59c73d3
|
2012-05-17T13:06:20
|
|
Optimize away git_text_gather_stats in diff
GProf shows `git_text_gather_stats` as the most expensive call
in large diffs. The function calculates a lot of information
that is not actually used and does not do so in a optimal
order. This introduces a tuned `git_buf_is_binary` function
that executes the same algorithm in a fraction of the time.
|
|
9a29f8d5
|
2012-05-04T07:55:09
|
|
diff: fix the diffing of two identical blobs
|
|
28ef7f9b
|
2012-05-03T17:25:01
|
|
diff: make git_diff_blobs() able to detect binary blobs
|
|
4f806761
|
2012-05-03T17:19:06
|
|
diff: fix the diffing of a concrete blob against a null one
|
|
245c5eae
|
2012-05-03T16:34:02
|
|
diff: When diffing two blobs, ensure the delta callback parameter is filled with relevant information
|
|
8d0f4675
|
2012-05-03T16:27:22
|
|
diff: remove unused parameter
|
|
f917481e
|
2012-05-03T16:37:25
|
|
Support reading attributes from index
Depending on the operation, we need to consider gitattributes
in both the work dir and the index. This adds a parameter to
all of the gitattributes related functions that allows user
control of attribute reading behavior (i.e. prefer workdir,
prefer index, only use index).
This fix also covers allowing us to check attributes (and
hence do diff and status) on bare repositories.
This was a somewhat larger change that I hoped because it had
to change the cache key used for gitattributes files.
|
|
40879fac
|
2012-05-02T15:59:02
|
|
Merge branch 'new-error-handling' into development
Conflicts:
.travis.yml
include/git2/diff.h
src/config_file.c
src/diff.c
src/diff_output.c
src/mwindow.c
src/path.c
tests-clar/clar_helpers.c
tests-clar/object/tree/frompath.c
tests/t00-core.c
tests/t03-objwrite.c
tests/t08-tag.c
tests/t10-refs.c
tests/t12-repo.c
tests/t18-status.c
tests/test_helpers.c
tests/test_main.c
|
|
3fd99be9
|
2012-03-05T09:30:17
|
|
Convert from strnlen to git_text_is_binary
Since strnlen is not supported on all platforms and since we
now have the shiny new git_text_is_binary in the filtering
code, let's convert diff binary detection to use the new stuff.
|
|
8b2bcfbe
|
2012-03-05T09:14:56
|
|
Copy values to avoid strict aliasing warning
To make this code more resilient to future changes, we'll
explicitly translate the libgit2 structure to the libxdiff
structure.
|
|
16b83019
|
2012-03-04T23:28:36
|
|
Fix usage of "new" for fieldname in public header
This should restore the ability to include libgit2 headers
in C++ projects.
Cherry picked 2de60205dfea2c4a422b2108a5e8605f97c2e895 from
development into new-error-handling.
|
|
1d2dd864
|
2012-04-29T19:42:51
|
|
diff: provide more context to the consumer of the callbacks
Update the callback to provide some information related to the file change being processed and the range of the hunk, when applicable.
|
|
eb3d71a5
|
2012-04-25T22:23:35
|
|
diff: fix generation of the header of a removal patch
|
|
66142ae0
|
2012-03-22T10:44:36
|
|
New status fixes
This adds support for roughly-right tracking of submodules
(although it does not recurse into submodules to detect
internal modifications a la core git), and it adds support
for including unmodified files in diff iteration if requested.
|
|
7826d577
|
2012-03-21T10:00:54
|
|
diff_output: remove unused parameter
Signed-off-by: schu <schu-github@schulog.org>
|
|
ae9e29fd
|
2012-03-06T16:14:31
|
|
Migrating diff to new error handling
Ended up migrating a bunch of upstream functions as well
including vector, attr_file, and odb in order to get this
to work right.
|
|
cb8a7961
|
2012-03-07T00:02:55
|
|
error-handling: Repository
This also includes droping `git_buf_lasterror` because it makes no sense
in the new system. Note that in most of the places were it has been
dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so
instead it should return a generic `-1` and obviously not throw
anything.
|
|
5621d809
|
2012-03-06T17:51:04
|
|
Rename git_oid_to_string to git_oid_tostr
To conform the naming scheme of git_oid_fromstr we should change the
name of git_oid_to_string to git_oid_tostr.
|
|
c4c4bc1f
|
2012-03-05T09:30:17
|
|
Convert from strnlen to git_text_is_binary
Since strnlen is not supported on all platforms and since we
now have the shiny new git_text_is_binary in the filtering
code, let's convert diff binary detection to use the new stuff.
|
|
28b486b2
|
2012-03-05T09:14:56
|
|
Copy values to avoid strict aliasing warning
To make this code more resilient to future changes, we'll
explicitly translate the libgit2 structure to the libxdiff
structure.
|
|
2de60205
|
2012-03-04T23:28:36
|
|
Fix usage of "new" for fieldname in public header
This should restore the ability to include libgit2 headers
in C++ projects.
|
|
529df4df
|
2012-03-02T15:57:06
|
|
Fixes for merge of filters branch
|
|
e1bcc191
|
2012-03-01T11:45:00
|
|
Revert GIT_STATUS constants to avoid issues
This reverts the changes to the GIT_STATUS constants and adds a
new enumeration to describe the type of change in a git_diff_delta.
I don't love this solution, but it should prevent strange errors
from occurring for now. Eventually, I would like to unify the
various status constants, but it needs a larger plan and I just
wanted to eliminate this breakage quickly.
|
|
854eccbb
|
2012-02-29T12:04:59
|
|
Clean up GIT_UNUSED macros on all platforms
It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5
did not fix the GIT_USUSED behavior on all platforms. This commit
walks through and really cleans things up more thoroughly, getting
rid of the unnecessary stuff.
To remove the use of some GIT_UNUSED, I ended up adding a couple
of new iterators for hashtables that allow you to iterator just
over keys or just over values.
In making this change, I found a bug in the clar tests (where we
were doing *count++ but meant to do (*count)++ to increment the
value). I fixed that but then found the test failing because it
was not really using an empty repo. So, I took some of the code
that I wrote for iterator testing and moved it to clar_helpers.c,
then made use of that to make it easier to open fixtures on a
per test basis even within a single test file.
|
|
74fa4bfa
|
2012-02-28T16:14:47
|
|
Update diff to use iterators
This is a major reorganization of the diff code. This changes
the diff functions to use the iterators for traversing the
content. This allowed a lot of code to be simplified. Also,
this moved the functions relating to outputting a diff into a
new file (diff_output.c).
This includes a number of other changes - adding utility
functions, extending iterators, etc. plus more tests for the
diff code. This also takes the example diff.c program much
further in terms of emulating git-diff command line options.
|