From a1fdea2855bf1c868d5613edb8cb6c4b062b83eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 24 Oct 2011 16:48:12 -0700 Subject: tree: implement tree diffing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- include/git2/tree.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include/git2') diff --git a/include/git2/tree.h b/include/git2/tree.h index fefd4c6c..3ff017fb 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 -- cgit v1.2.1