summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-02-21 12:40:33 -0800
committerRussell Belfer <rb@github.com>2013-02-21 12:40:33 -0800
commit960a04dd56d89e94b5092be19ba9704b2d292dba (patch)
treef85c54d36d40f46b3ed31fecfa284f197973c6c3 /include/git2/diff.h
parent71a3d27ea686845811f04314d02798b4f1745046 (diff)
downloadlibgit2-960a04dd56d89e94b5092be19ba9704b2d292dba.tar.gz
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.
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r--include/git2/diff.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 7f165041a..379f4694e 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -379,7 +379,7 @@ typedef struct git_diff_patch git_diff_patch;
typedef enum {
/** look for renames? (`--find-renames`) */
GIT_DIFF_FIND_RENAMES = (1 << 0),
- /** consider old size of modified for renames? (`--break-rewrites=N`) */
+ /** consider old side of modified for renames? (`--break-rewrites=N`) */
GIT_DIFF_FIND_RENAMES_FROM_REWRITES = (1 << 1),
/** look for copies? (a la `--find-copies`) */
@@ -897,11 +897,12 @@ GIT_EXTERN(int) git_diff_patch_to_str(
*
* NULL is allowed for either `old_blob` or `new_blob` and will be treated
* as an empty blob, with the `oid` set to NULL in the `git_diff_file` data.
+ * Passing NULL for both blobs is a noop; no callbacks will be made at all.
*
- * We do run a binary content check on the two blobs and if either of the
- * blobs looks like binary data, the `git_diff_delta` binary attribute will
- * be set to 1 and no call to the hunk_cb nor line_cb will be made (unless
- * you pass `GIT_DIFF_FORCE_TEXT` of course).
+ * We do run a binary content check on the blob content and if either blob
+ * looks like binary data, the `git_diff_delta` binary attribute will be set
+ * to 1 and no call to the hunk_cb nor line_cb will be made (unless you pass
+ * `GIT_DIFF_FORCE_TEXT` of course).
*
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
@@ -921,6 +922,11 @@ GIT_EXTERN(int) git_diff_blobs(
* so the `git_diff_file` parameters to the callbacks will be faked a la the
* rules for `git_diff_blobs()`.
*
+ * Passing NULL for `old_blob` will be treated as an empty blob (i.e. the
+ * `file_cb` will be invoked with GIT_DELTA_ADDED and the diff will be the
+ * entire content of the buffer added). Passing NULL to the buffer will do
+ * the reverse, with GIT_DELTA_REMOVED and blob content removed.
+ *
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
GIT_EXTERN(int) git_diff_blob_to_buffer(