libgit2

git_diff_find_options

Version:

Control behavior of rename and copy detection

These options mostly mimic parameters that can be passed to git-diff.

  • rename_threshold is the same as the -M option with a value
  • copy_threshold is the same as the -C option with a value
  • rename_from_rewrite_threshold matches the top of the -B option
  • break_rewrite_threshold matches the bottom of the -B option
  • rename_limit is the maximum number of matches to consider for a particular file. This is a little different from the -l option to regular Git because we will still process up to this many matches before abandoning the search.

The metric option allows you to plug in a custom similarity metric. Set it to NULL for the default internal metric which is based on sampling hashes of ranges of data in the file. The default metric is a pretty good similarity approximation that should work fairly well for both text and binary data, and is pretty fast with fixed memory overhead.

Signature

typedef struct git_diff_find_options { unsigned int version uint32_t flags uint16_t rename_threshold uint16_t rename_from_rewrite_threshold uint16_t copy_threshold uint16_t break_rewrite_threshold size_t rename_limit git_diff_similarity_metric *metric };

Members

unsigned int
version
uint32_t
flags

Combination of git_diff_find_t values (default GIT_DIFF_FIND_BY_CONFIG). NOTE: if you don't explicitly set this, diff.renames could be set to false, resulting in git_diff_find_similar doing nothing.

uint16_t
rename_threshold

Similarity to consider a file renamed (default 50)

uint16_t
rename_from_rewrite_threshold

Similarity of modified to be eligible rename source (default 50)

uint16_t
copy_threshold

Similarity to consider a file a copy (default 50)

uint16_t
break_rewrite_threshold

Similarity to split modify into delete/add pair (default 60)

size_t
rename_limit

Maximum similarity sources to examine for a file (somewhat like git-diff's -l option or diff.renameLimit config) (default 200)

metric

Pluggable similarity metric; pass NULL to use internal metric

Parameter To

Versions