summaryrefslogtreecommitdiff
path: root/include/git2/tree.h
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-10-24 16:48:12 -0700
committerVicent Marti <tanoku@gmail.com>2011-12-03 17:47:06 +0100
commita1fdea2855bf1c868d5613edb8cb6c4b062b83eb (patch)
tree81592a263317f7d7efb2f0caf3eb12299581e5ca /include/git2/tree.h
parenta22b14d32dd8d5f06f121aa154d45bac3b10a305 (diff)
downloadlibgit2-a1fdea2855bf1c868d5613edb8cb6c4b062b83eb.tar.gz
tree: implement tree diffing
For each difference in the trees, the callback gets called with the relevant information so the user can fill in their own data structures. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'include/git2/tree.h')
-rw-r--r--include/git2/tree.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/git2/tree.h b/include/git2/tree.h
index fefd4c6c3..3ff017fbf 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -314,5 +314,39 @@ enum git_treewalk_mode {
GIT_EXTERN(int) git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload);
/** @} */
+
+typedef enum {
+ GIT_STATUS_ADDED = 1,
+ GIT_STATUS_DELETED = 2,
+ GIT_STATUS_MODIFIED = 3,
+} git_status_t;
+
+typedef struct {
+ unsigned int old_attr;
+ unsigned int new_attr;
+ git_oid old_oid;
+ git_oid new_oid;
+ git_status_t status;
+ const char *path;
+} git_tree_diff_data;
+
+typedef int (*git_tree_diff_cb)(const git_tree_diff_data *ptr, void *data);
+
+/**
+ * Diff two trees
+ *
+ * Compare two trees. For each difference in the trees, the callback
+ * will be called with a git_tree_diff_data filled with the relevant
+ * information.
+ *
+ * @param old the "old" tree
+ * @param newer the "newer" tree
+ * @param cb callback
+ * @param data data to give to the callback
+ * @return GIT_SUCCESS or an error code
+ */
+int git_tree_diff(git_tree *old, git_tree *newer, git_tree_diff_cb cb, void *data);
+
+
GIT_END_DECL
#endif