From 1df4320fa25d3784b035936b35725460d46f1ca0 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Mon, 20 Jan 2014 20:20:38 +0400 Subject: diffcore-order: export generic ordering interface diffcore_order() interface only accepts a queue of `struct diff_filepair`. In the next patches, we'll want to order `struct combine_diff_path` by path, so let's first rework diffcore-order to also provide generic low-level interface for ordering arbitrary objects, provided they have path accessors. The new interface is: - `struct obj_order` for describing objects to ordering routine, and - order_objects() for actually doing the ordering work. Signed-off-by: Kirill Smelkov Signed-off-by: Junio C Hamano --- diffcore.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'diffcore.h') diff --git a/diffcore.h b/diffcore.h index 79de8cf28d..cbe9e62b49 100644 --- a/diffcore.h +++ b/diffcore.h @@ -109,6 +109,20 @@ extern void diffcore_merge_broken(void); extern void diffcore_pickaxe(struct diff_options *); extern void diffcore_order(const char *orderfile); +/* low-level interface to diffcore_order */ +struct obj_order { + void *obj; /* setup by caller */ + + /* setup/used by order_objects() */ + int orig_order; + int order; +}; + +typedef const char *(*obj_path_fn_t)(void *obj); + +void order_objects(const char *orderfile, obj_path_fn_t obj_path, + struct obj_order *objs, int nr); + #define DIFF_DEBUG 0 #if DIFF_DEBUG void diff_debug_filespec(struct diff_filespec *, int, const char *); -- cgit v1.2.3