Russell Belfer [Sun, 13 Jan 2013 18:06:09 +0000 (10:06 -0800)]
Some similarity metric adjustments
This makes the text similarity metric treat \r as equivalent
to \n and makes it skip whitespace immediately following a line
terminator, so line indentation will have less effect on the
difference measurement (and so \r\n will be treated as just a
single line terminator).
This also separates the text and binary hash calculators into
two separate functions instead of have more if statements inside
the loop. This should make it easier to have more differentiated
heuristics in the future if we so wish.
Russell Belfer [Sat, 12 Jan 2013 06:13:02 +0000 (22:13 -0800)]
Initial implementation of similarity scoring algo
This adds a new `git_buf_text_hashsig` type and functions to
generate these hash signatures and compare them to give a
similarity score. This can be plugged into diff similarity
scoring.
Russell Belfer [Wed, 20 Feb 2013 19:58:21 +0000 (11:58 -0800)]
Add more treebuilder tests
The recent changes with git_treebuilder_entrycount point out that
the test coverage for git_treebuilder_remove and
git_treebuilder_entrycount is completely absent. This adds tests.
Russell Belfer [Wed, 20 Feb 2013 18:58:56 +0000 (10:58 -0800)]
Some code cleanups in tree.c
This replaces most of the explicit vector iteration with calls
to git_vector_foreach, adds in some git__free and giterr_clear
calls to clean up during some error paths, and a couple of
other code simplifications.
Russell Belfer [Wed, 20 Feb 2013 18:50:01 +0000 (10:50 -0800)]
Store treebuilder length separately from entries vec
The treebuilder entries vector flags removed items which means
we can't rely on the entries vector length to accurately get the
number of entries. This adds an entrycount value and maintains it
while updating the treebuilder entries.
Russell Belfer [Sat, 16 Feb 2013 00:02:45 +0000 (16:02 -0800)]
Clear up warnings from cppcheck
The cppcheck static analyzer generates warnings for a bunch of
places in the libgit2 code base. All the ones fixed in this
commit are actually false positives, but I've reorganized the
code to hopefully make it easier for static analysis tools to
correctly understand the structure. I wouldn't do this if I
felt like it was making the code harder to read or worse for
humans, but in this case, these fixes don't seem too bad and will
hopefully make it easier for better analysis tools to get at any
real issues.
Russell Belfer [Sat, 16 Feb 2013 00:01:31 +0000 (16:01 -0800)]
Fix memory leak in p_getaddrinfo on Amiga
If gethostbyname() fails on platforms with NO_ADDRINFO, the code
leaks the struct addrinfo that was allocated. This fixes that
(and a number of code formatting issues in that area of code in
src/posix.c).
Russell Belfer [Fri, 15 Feb 2013 23:58:13 +0000 (15:58 -0800)]
Add rudimentary error checks and reformat comments
There were a number of functions assigning their return value to
`error` without much explanation. I added in some rudimentary
error checking to help flesh out the example.
Also, I reformatted all of the comments down to 80 cols (and in
some cases, slightly updated the wording).
Russell Belfer [Tue, 15 Jan 2013 17:24:17 +0000 (09:24 -0800)]
Add FORCE_TEXT check into git_diff_blobs code path
`git_diff_blobs` and `git_diff_blob_to_buffer` skip the step
where we check file attributes because they don't have a filename
associated with the data. Unfortunately, this meant they were also
skipping the check for the GIT_DIFF_FORCE_TEXT option and so you
could not force a diff of an apparent binary file. This adds the
force text check into their code path.
yorah [Fri, 25 Jan 2013 16:35:46 +0000 (17:35 +0100)]
diff: add a notify callback to `git_diff__from_iterators`
The callback will be called for each file, just before the `git_delta_t` gets inserted into the diff list.
When the callback:
- returns < 0, the diff process will be aborted
- returns > 0, the delta will not be inserted into the diff list, but the diff process continues
- returns 0, the delta is inserted into the diff list, and the diff process continues
yorah [Fri, 18 Jan 2013 15:37:13 +0000 (16:37 +0100)]
Return the matched pathspec pattern in `git_pathspec_match_path`
Instead of returning directly the pattern as the return value, I used an
out parameter, because the function also tests if the passed pathspecs
vector is empty. If yes, it considers that the path "matches", but in
that case there is no matched pattern per se.
Sven Strickroth [Fri, 1 Feb 2013 15:17:34 +0000 (16:17 +0100)]
Win32: Make sure error messages are consistently UTF-8 encoded
W/o this a libgit2 error message could have a mixed encoding:
e.g. a filename in UTF-8 combined with a native Windows error message
encoded with the local code page.