Commit Graph

4496 Commits

Author SHA1 Message Date
Vicent Marti
5fa8abb868 w32-posix: Wrap the timezone declaration with a clause
Allows compilation in newer versions of MinGW that already defined it.
2013-02-28 17:36:20 +01:00
Russell Belfer
f708c89fa6 fixing some warnings on Windows 2013-02-27 15:15:39 -08:00
Russell Belfer
11b5beb7ba use cdecl for hashsig sorting functions on Windows 2013-02-27 15:07:28 -08:00
Vicent Martí
e68e33f33d Merge pull request #1233 from arrbee/file-similarity-metric
Add file similarity scoring to diff rename/copy detection
2013-02-27 14:50:32 -08:00
Russell Belfer
9f9477d650 Merge pull request #1372 from ethomson/checkout_workdir_end
don't dereference at the end of the workdir iterator
2013-02-27 14:21:41 -08:00
Russell Belfer
18f0826408 Make mode handling during init more like git
When creating files, instead of actually using GIT_FILEMODE_BLOB
and the other various constants that happen to correspond to
mode values, apparently I should be just using 0666 and 0777, and
relying on the umask to clear bits and make the value sane.

This fixes the rules for copying a template directory and fixes
the checks to match that new behavior.  (Further changes to the
checkout logic to follow separately.)
2013-02-27 13:44:15 -08:00
Edward Thomson
395509ffcd don't dereference at the end of the workdir iterator 2013-02-27 15:35:52 -06:00
Vicent Martí
c493f8211f Merge pull request #1371 from csware/version-constants
Win32: Use constants in version resource definitions where possible
2013-02-27 11:01:16 -08:00
Sven Strickroth
82ac1f7678 Win32: Use constants in version resource definitions where possible
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-02-27 19:48:02 +01:00
Russell Belfer
0d1b094b07 Fix portability issues on Windows
The new tests were not taking core.filemode into account when
testing file modes after repo initialization.  Fixed that and some
other Windows warnings that have crept in.
2013-02-26 13:15:06 -08:00
Russell Belfer
3c42e4ef74 Fix initialization of repo directories
When PR #1359 removed the hooks from the test resources/template
directory, it made me realize that the tests for
git_repository_init_ext using templates must be pretty shabby
because we could not have been testing if the hooks were getting
created correctly.

So, this started with me recreating a couple of hooks, including
a sample and symlink, and adding tests that they got created
correctly in the various circumstances, including with the SHARED
modes, etc.  Unfortunately this uncovered some issues with how
directories and symlinks were copied and chmod'ed.  Also, there
was a FIXME in the code related to the chmod behavior as well.

Going back over the directory creation logic for setting up a
repository, I found it was a little difficult to read and could
result in creating and/or chmod'ing directories that the user
almost certainly didn't intend.

So that let to this work which makes repo initialization much
more careful (and hopefully easier to follow).  It required a
couple of extensions / changes to core fileops utilities, but I
also think those are for the better, at least for git_futils_cp_r
in terms of being careful about what actions it takes.
2013-02-26 11:43:14 -08:00
Vicent Martí
6990377786 Merge pull request #1368 from scunz/inc_ref
Increment reference counter in git_repository_set_config
2013-02-26 09:29:27 -08:00
Sascha Cunz
25e7c9b7a6 Increment reference counter in git_repository_set_config
This fixes #1365
2013-02-26 18:21:03 +01:00
Edward Thomson
3e212548f8 Merge pull request #1364 from martinwoodward/thank-martin
Give props to Martin Pool
2013-02-26 07:06:42 -08:00
Martin Woodward
5c46937b3a Give props to Martin Pool
Martin Pool was the original author of the code referenced in the clone
example. Make note that he's given his permission and also give him the
proper credit.
2013-02-26 09:00:37 +00:00
Michael Schubert
8005c6d420 Revert "hash: remove git_hash_init from internal api"
This reverts commit efe7fad6c9, except for
the indentation fixes.
2013-02-26 01:08:34 +01:00
Vicent Martí
f657688bc7 Merge pull request #1363 from schu/hash-initialization
hash: remove git_hash_init from internal api
2013-02-25 15:41:56 -08:00
Michael Schubert
efe7fad6c9 hash: remove git_hash_init from internal api
Along with that, fix indentation in tests-clar/object/raw/hash.c
2013-02-26 00:23:00 +01:00
Michael Schubert
be225be785 tests/pack: fixup 6774b10
Initialize the hash ctx with git_hash_ctx_init, not git_hash_init.
2013-02-25 23:36:25 +01:00
Vicent Martí
989abe9be4 Merge pull request #1362 from schu/packbuilder-nits
packbuilder: minor improvements
2013-02-25 14:03:42 -08:00
Michael Schubert
6774b1071f tests/pack: do strict check of testpack's SHA1 hash 2013-02-25 22:22:15 +01:00
Michael Schubert
fcc265fef8 pack.h: improve docs on how to create a packfile 2013-02-25 22:22:15 +01:00
Vicent Martí
25a0831f2d Merge pull request #1359 from martinwoodward/remove-sample-hooks
Remove sample hook files
2013-02-25 09:07:45 -08:00
Martin Woodward
fc6c5b5001 Remove sample hook files
Getting rid of sample hook files from test repos as they just take up
space with no value.
2013-02-25 17:03:05 +00:00
Vicent Martí
5eeb357df8 Merge pull request #1355 from phkelley/development
Portability fixes for Solaris
2013-02-23 03:39:11 -08:00
Vicent Martí
68fec637a2 Merge pull request #1356 from arrbee/fix-directory-as-ignore-file
Do not fail if .gitignore is directory
2013-02-22 12:26:01 -08:00
Russell Belfer
37d9168608 Do not fail if .gitignore is directory
This is designed to fix libgit2sharp #350 where if .gitignore is
a directory we abort all operations that process ignores instead
of just skipping it as core git does.

Also added test that fails without this change and passes with it.
2013-02-22 12:21:54 -08:00
Russell Belfer
1be4ba9842 More rename detection tests
This includes tests for crlf changes, whitespace changes with the
default comparison and with the ignore whitespace comparison, and
more sensitivity checking for the comparison code.
2013-02-22 11:13:01 -08:00
Philip Kelley
7beeb3f420 Rename 'exp' so it doesn't conflict with exp() 2013-02-22 14:03:44 -05:00
Russell Belfer
0a0089131f Minor improvements to find_similar code
This moves a couple of checks outside of the inner loop of the
find_similar rename/copy detection phase that are only dependent
on the "from" side of a detection.

Also, this replaces the inefficient initialization of the
options structure when a value is not provided explicitly by the
user.
2013-02-22 10:21:02 -08:00
Russell Belfer
f827589067 Replace static data with configured metric
Instead of creating three git_diff_similarity_metric statically
for the various config options, just create the metric structure
on demand and populate it, using the payload to specific the
extra flags that should be passed to the hashsig.  This removes
a level of obfuscation from the code, I think.
2013-02-22 10:19:50 -08:00
Russell Belfer
6f9d5ce818 Fix tests for find_similar and related
This fixes both a test that I broke in diff::patch where I was
relying on the current state of the working directory for the
renames test data and fixes an unstable test in diff::rename
where the environment setting for the "diff.renames" config was
being allowed to influence the test results.
2013-02-22 10:17:08 -08:00
Vicent Martí
06eaa06f26 Merge pull request #1343 from nulltoken/topic/remote_orphaned_branch
Teach git_branch_remote_name() to work with orphaned heads
2013-02-22 09:48:47 -08:00
Vicent Martí
698bf1da0e Merge pull request #1354 from nulltoken/fix/stash-drop
Fix git_stash_drop()
2013-02-22 09:48:34 -08:00
Philip Kelley
6c72035fbc Portability fixes for Solaris 2013-02-22 12:23:14 -05:00
nulltoken
bbc53e4f93 branch: refactor git_branch_remote_name() tests 2013-02-22 17:04:25 +01:00
nulltoken
c1b5e8c42b branch: Make git_branch_remote_name() cope with orphaned heads 2013-02-22 17:04:23 +01:00
nulltoken
9ccab8dfb8 stash: Update the reference when dropping the topmost stash 2013-02-22 15:25:59 +01:00
nulltoken
39bcb4deb8 stash: Refactor stash::drop tests 2013-02-22 15:25:58 +01:00
nulltoken
d788499a10 ignore: enhance git_ignore_path_is_ignored() test coverage 2013-02-22 15:25:57 +01:00
Russell Belfer
d4b747c1cb Add diff rename tests with partial similarity
This adds some new tests that actually exercise the similarity
metric between files to detect renames, copies, and split modified
files that are too heavily modified.

There is still more testing to do - these tests are just partially
covering the cases.

There is also one bug fix in this where a change set with only
MODIFY being broken into ADD/DELETE (due to low self-similarity)
without any additional RENAMED entries would end up not processing
the split requests (because the num_rewrites counter got reset).
2013-02-21 16:44:44 -08:00
Russell Belfer
960a04dd56 Initial integration of similarity metric to diff
This is the initial integration of the similarity metric into
the `git_diff_find_similar()` code path.  The existing tests all
pass, but the new functionality isn't currently well tested.  The
integration does go through the pluggable metric interface, so it
should be possible to drop in an alternative to the internal
metric that libgit2 implements.

This comes along with a behavior change for an existing interface;
namely, passing two NULLs to git_diff_blobs (or passing NULLs to
git_diff_blob_to_buffer) will now call the file_cb parameter zero
times instead of one time.  I know it's strange that that change
is paired with this other change, but it emerged from some
initialization changes that I ended up making.
2013-02-21 12:40:33 -08:00
Vicent Martí
0309e85045 Merge pull request #1352 from ethomson/reuc_sort
add a sorter to the reuc on index creation
2013-02-21 09:05:48 -08:00
Edward Thomson
eb5ffd1944 add a sorter to the reuc on index creation 2013-02-21 11:00:29 -06:00
Russell Belfer
71a3d27ea6 Replace diff delta binary with flags
Previously the git_diff_delta recorded if the delta was binary.
This replaces that (with no net change in structure size) with
a full set of flags.  The flag values that were already in use
for individual git_diff_file objects are reused for the delta
flags, too (along with renaming those flags to make it clear that
they are used more generally).

This (a) makes things somewhat more consistent (because I was
using a -1 value in the "boolean" binary field to indicate unset,
whereas now I can just use the flags that are easier to understand),
and (b) will make it easier for me to add some additional flags to
the delta object in the future, such as marking the results of a
copy/rename detection or other deltas that might want a special
indicator.

While making this change, I officially moved some of the flags that
were internal only into the private diff header.

This also allowed me to remove a gross hack in rename/copy detect
code where I was overwriting the status field with an internal
value.
2013-02-20 15:10:21 -08:00
Russell Belfer
9bc8be3d7e Refine pluggable similarity API
This plugs in the three basic similarity strategies for handling
whitespace via internal use of the pluggable API.  In so doing, I
realized that the use of git_buf in the hashsig API was not needed
and actually just made it harder to use, so I tweaked that API as
well.

Note that the similarity metric is still not hooked up in the
find_similarity code - this is just setting out the function that
will be used.
2013-02-20 15:09:41 -08:00
Russell Belfer
a235e9d355 Pluggable similarity metric API 2013-02-20 15:09:41 -08:00
Russell Belfer
aa6432604e More tests of file signatures with whitespace opts
Seems to be working pretty well...
2013-02-20 15:09:41 -08:00
Russell Belfer
5e5848eb15 Change similarity metric to sampled hashes
This moves the similarity metric code out of buf_text and into a
new file.  Also, this implements a different approach to similarity
measurement based on a Rabin-Karp rolling hash where we only keep
the top 100 and bottom 100 hashes.  In theory, that should be
sufficient samples to given a fairly accurate measurement while
limiting the amount of data we keep for file signatures no matter
how large the file is.
2013-02-20 15:09:40 -08:00
Russell Belfer
99ba8f2322 wip: adding metric to diff 2013-02-20 15:09:40 -08:00