From c99db9d292c5f63c83ae2b441a67121d76553413 Mon Sep 17 00:00:00 2001 From: Brian Downing Date: Thu, 14 Aug 2008 00:36:50 -0500 Subject: Make xdi_diff_outf interface for running xdiff_outf diffs To prepare for the need to initialize and release resources for an xdi_diff with the xdiff_outf output function, make a new function to wrap this usage. Old: ecb.outf = xdiff_outf; ecb.priv = &state; ... xdi_diff(file_p, file_o, &xpp, &xecfg, &ecb); New: xdi_diff_outf(file_p, file_o, &state.xm, &xpp, &xecfg, &ecb); Signed-off-by: Brian Downing Signed-off-by: Junio C Hamano --- xdiff-interface.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index f7f791d96b..6f3b361a84 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -14,7 +14,9 @@ struct xdiff_emit_state { }; int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb); -int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf); +int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2, + struct xdiff_emit_state *state, xpparam_t const *xpp, + xdemitconf_t const *xecfg, xdemitcb_t *xecb); int parse_hunk_header(char *line, int len, int *ob, int *on, int *nb, int *nn); -- cgit v1.2.3 From b463776086a12c587f6d91c0347641fb6f7ddd72 Mon Sep 17 00:00:00 2001 From: Brian Downing Date: Thu, 14 Aug 2008 00:36:51 -0500 Subject: Use strbuf for struct xdiff_emit_state's remainder Continually xreallocing and freeing the remainder member of struct xdiff_emit_state was a noticeable performance hit. Use a strbuf instead. This yields a decent performance improvement on "git blame" on certain repositories. For example, before this commit: $ time git blame -M -C -C -p --incremental server.c >/dev/null 101.52user 0.17system 1:41.73elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+39561minor)pagefaults 0swaps With this commit: $ time git blame -M -C -C -p --incremental server.c >/dev/null 80.38user 0.30system 1:20.81elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+50979minor)pagefaults 0swaps Signed-off-by: Brian Downing Signed-off-by: Junio C Hamano --- xdiff-interface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index 6f3b361a84..f6a1ec2220 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -2,6 +2,7 @@ #define XDIFF_INTERFACE_H #include "xdiff/xdiff.h" +#include "strbuf.h" struct xdiff_emit_state; @@ -9,8 +10,7 @@ typedef void (*xdiff_emit_consume_fn)(void *, char *, unsigned long); struct xdiff_emit_state { xdiff_emit_consume_fn consume; - char *remainder; - unsigned long remainder_size; + struct strbuf remainder; }; int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb); -- cgit v1.2.3 From 8a3f524bf2ac534b313a7d8e70cc164cef744949 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 13 Aug 2008 23:18:22 -0700 Subject: xdiff-interface: hide the whole "xdiff_emit_state" business from the caller This further enhances xdi_diff_outf() interface so that it takes two common parameters: the callback function that processes one line at a time, and a pointer to its application specific callback data structure. xdi_diff_outf() creates its own "xdiff_emit_state" structure and stashes these two away inside it, which is used by the lowest level output function in the xdiff_outf() callchain, consume_one(), to call back to the application layer. With this restructuring, we lift the requirement that the caller supplied callback data structure embeds xdiff_emit_state structure as its first member. Signed-off-by: Junio C Hamano --- xdiff-interface.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index f6a1ec2220..558492ba38 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -2,20 +2,13 @@ #define XDIFF_INTERFACE_H #include "xdiff/xdiff.h" -#include "strbuf.h" - -struct xdiff_emit_state; typedef void (*xdiff_emit_consume_fn)(void *, char *, unsigned long); -struct xdiff_emit_state { - xdiff_emit_consume_fn consume; - struct strbuf remainder; -}; - int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb); int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2, - struct xdiff_emit_state *state, xpparam_t const *xpp, + xdiff_emit_consume_fn fn, void *consume_callback_data, + xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *xecb); int parse_hunk_header(char *line, int len, int *ob, int *on, -- cgit v1.2.3 From b541248467fa47979a34e3f1c5bbe3308fbdc4d1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 29 Aug 2008 10:49:56 -0700 Subject: merge.conflictstyle: choose between "merge" and "diff3 -m" styles This teaches "git merge-file" to honor merge.conflictstyle configuration variable, whose value can be "merge" (default) or "diff3". Signed-off-by: Junio C Hamano --- xdiff-interface.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index f7f791d96b..cfe3215cb2 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -22,5 +22,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename); int buffer_is_binary(const char *ptr, unsigned long size); extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line); +extern int git_xmerge_config(const char *var, const char *value, void *cb); +extern int git_xmerge_style; #endif -- cgit v1.2.3 From a013585b20ac757b0e75a72181ffa44674f35235 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 18 Sep 2008 17:42:48 -0500 Subject: diff.c: associate a flag with each pattern and use it for compiling regex This is in preparation for allowing extended regular expression patterns. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- xdiff-interface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index f7f791d96b..33cab9dd59 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -21,6 +21,6 @@ int parse_hunk_header(char *line, int len, int read_mmfile(mmfile_t *ptr, const char *filename); int buffer_is_binary(const char *ptr, unsigned long size); -extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line); +extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags); #endif -- cgit v1.2.3 From 86295bb6bac1482d29650d1f77f19d8e7a7cc2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 25 Oct 2008 15:31:15 +0200 Subject: add xdi_diff_hunks() for callers that only need hunk lengths Based on a patch by Brian Downing, this uses the xdiff emit_func feature to implement xdi_diff_hunks(). It's a function that calls a callback for each hunk of a diff, passing its lengths. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- xdiff-interface.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index eaf9cd3498..7352b9a9c2 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -4,12 +4,16 @@ #include "xdiff/xdiff.h" typedef void (*xdiff_emit_consume_fn)(void *, char *, unsigned long); +typedef void (*xdiff_emit_hunk_consume_fn)(void *, long, long, long); int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb); int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2, xdiff_emit_consume_fn fn, void *consume_callback_data, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *xecb); +int xdi_diff_hunks(mmfile_t *mf1, mmfile_t *mf2, + xdiff_emit_hunk_consume_fn fn, void *consume_callback_data, + xpparam_t const *xpp, xdemitconf_t *xecfg); int parse_hunk_header(char *line, int len, int *ob, int *on, int *nb, int *nn); -- cgit v1.2.3 From 8cfe5f1cd5dabc3a21bc792327747deefeff6dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 2 Jul 2009 00:01:43 +0200 Subject: userdiff: add xdiff_clear_find_func() xdiff_set_find_func() is used to set user defined regular expressions for finding function signatures. Add xdiff_clear_find_func(), which frees the memory allocated by the former, making the API complete. Also, use the new function in diff.c (the only call site of xdiff_set_find_func()) to clean up after ourselves. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- xdiff-interface.h | 1 + 1 file changed, 1 insertion(+) (limited to 'xdiff-interface.h') diff --git a/xdiff-interface.h b/xdiff-interface.h index 7352b9a9c2..55572c39a1 100644 --- a/xdiff-interface.h +++ b/xdiff-interface.h @@ -21,6 +21,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename); int buffer_is_binary(const char *ptr, unsigned long size); extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags); +extern void xdiff_clear_find_func(xdemitconf_t *xecfg); extern int git_xmerge_config(const char *var, const char *value, void *cb); extern int git_xmerge_style; -- cgit v1.2.3