Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented parameters for Diff.find_similar() #396

Merged
merged 2 commits into from
Jul 28, 2014

Conversation

ArnoVanLumig
Copy link
Contributor

Diff.find_similar now supports the parameters that are exposed by libgit2's git_diff_find_similar.

Parameters supported are rename_threshold, copy_threshold,
rename_from_rewrite_threshold, break_rewrite_threshold and rename_limit

Diff.find_similar now supports the parameters that are exposed by
libgit2's git_diff_find_similar.

Parameters supported are rename_threshold, copy_threshold,
rename_from_rewrite_threshold, break_rewrite_threshold and rename_limit
@ArnoVanLumig
Copy link
Contributor Author

This pull request relates to issue #394, but it doesn't seem to solve it (similarity parameters appear to be ignored)

{
int err;
git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT;

if (!PyArg_ParseTuple(args, "|i", &opts.flags))
uint16_t rename_threshold, copy_threshold, rename_from_rewrite_threshold, break_rewrite_threshold;
size_t rename_limit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these values will be unitialised if they're not passed. Instead of this, you should let PyArg_ParseTupleAndKeywords write into the options structure directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I actually figured that out myself but forgot to commit and push it... Thanks for the heads-up!

@ArnoVanLumig
Copy link
Contributor Author

Okay, so it turns out that it does work. I previously tested it with a repo with very small files, and apparently libgit2 refuses to compute similarity on small files. However, when 100% similarity is required it uses a different algorithm (just comparing hashes) which does not check file size.

Tested it with larger files now and it works for me.

@jdavid jdavid merged commit e31f0ac into libgit2:master Jul 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants