summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-01-27 11:29:25 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-03-02 15:49:28 -0800
commitcd33323b7251e0bb15c5ee476e918859b661cc5f (patch)
treeca31375d8108a4186e664dc0f974ebf1f6a92fba /include
parent8b75f7f3ea91b3efc4e58a7bf737aedfd19671e7 (diff)
downloadlibgit2-cd33323b7251e0bb15c5ee476e918859b661cc5f.tar.gz
Initial implementation of git_diff_blob
This gets the basic plumbing in place for git_diff_blob. There is a known issue where additional parameters like the number of lines of context to display on the diff are not working correctly (which leads one of the new unit tests to fail).
Diffstat (limited to 'include')
-rw-r--r--include/git2/diff.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
new file mode 100644
index 000000000..1d3a8d408
--- /dev/null
+++ b/include/git2/diff.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009-2012 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_git_diff_h__
+#define INCLUDE_git_diff_h__
+
+#include "common.h"
+#include "types.h"
+#include "oid.h"
+#include "tree.h"
+#include "refs.h"
+
+/**
+ * @file git2/diff.h
+ * @brief Git tree and file differencing routines.
+ * @ingroup Git
+ * @{
+ */
+GIT_BEGIN_DECL
+
+typedef int (*git_diff_file_fn)(
+ void *cb_data,
+ const git_oid *old,
+ const char *old_path,
+ int old_mode,
+ const git_oid *new, /* hashed object if from work tree */
+ const char *new_path,
+ int new_mode);
+
+typedef int (*git_diff_hunk_fn)(
+ void *cb_data,
+ int old_start,
+ int old_lines,
+ int new_start,
+ int new_lines);
+
+#define GIT_DIFF_LINE_CONTEXT 0
+#define GIT_DIFF_LINE_ADDITION 1
+#define GIT_DIFF_LINE_DELETION 2
+
+typedef int (*git_diff_line_fn)(
+ void *cb_data,
+ int origin, /* GIT_DIFF_LINE value from above */
+ const char *content,
+ size_t content_len);
+
+typedef struct {
+ int context_lines;
+ int interhunk_lines;
+ int ignore_whitespace;
+
+ git_diff_file_fn file_cb;
+ git_diff_hunk_fn hunk_cb;
+ git_diff_line_fn line_cb;
+ void *cb_data;
+} git_diff_opts;
+
+
+GIT_EXTERN(int) git_diff_blobs(
+ git_repository *repo,
+ git_blob *old,
+ git_blob *new,
+ git_diff_opts *options);
+
+GIT_EXTERN(int) git_diff_trees(
+ git_repository *repo,
+ git_tree *old,
+ git_tree *new,
+ git_diff_opts *options);
+
+GIT_EXTERN(int) git_diff_index(
+ git_repository *repo,
+ git_tree *old,
+ git_diff_opts *options);
+
+/* pass NULL for the git_tree to diff workdir against index */
+GIT_EXTERN(int) git_diff_workdir(
+ git_repository *repo,
+ git_tree *old,
+ git_diff_opts *options);
+
+GIT_EXTERN(int) git_diff_workdir_file(
+ git_repository *repo,
+ git_blob *old,
+ const char *path,
+ git_diff_opts *options);
+
+/* pass git_objects to diff against or NULL for index.
+ * can handle: blob->blob, tree->index, tree->tree
+ * it will be an error if object types don't match
+ */
+/* pass git_object to diff WT against or NULL for index
+ * can handle: index->wt, tree->wt, blob->wt with path
+ */
+
+GIT_END_DECL
+
+/** @} */
+
+#endif