Re: [PATCH v2 1/1] xdiff: provide indirection to git functions

Started by Junio C Hamano on Feb 25, 2022

open the first message on its own page

Message details and related content
Edward Thomson [off-list ref] writes:
Provide an indirection layer into the git-specific functionality and
utilities in `git-xdiff.h`, prefixing those types and functions with
`xdl_` (and `XDL_` for macros).  This allows other projects that use
git's xdiff implementation to keep up-to-date; they can now take all the
files _except_ `git-xdiff.h`, which they have customized for their own
environment.
Continuing the "what do they exactly do" line of thought, the above
is not quite in line with what I heard.  They take all the files
including git-xdiff.h and they must modify git-xdiff.h to match
their environment.

In any case, ...
quoted hunk
diff --git a/xdiff/git-xdiff.h b/xdiff/git-xdiff.h
new file mode 100644
index 0000000000..664a7c1351
--- /dev/null
+++ b/xdiff/git-xdiff.h
@@ -0,0 +1,16 @@
+#ifndef GIT_XDIFF_H
+#define GIT_XDIFF_H
... here is a good place to spell the expectation out, i.e. that
they are expected to change this file to match their system, and
that all the things they see below here (including the inclusion of
git-compat-util.h) is specific to git-core they are expected to rip
out and replace.
quoted hunk
+
+#include "git-compat-util.h"
+
+#define xdl_malloc(x) xmalloc(x)
+#define xdl_free(ptr) free(ptr)
+#define xdl_realloc(ptr,x) xrealloc(ptr,x)
+
+#define xdl_regex_t regex_t
+#define xdl_regmatch_t regmatch_t
+#define xdl_regexec_buf(p, b, s, n, m, f) regexec_buf(p, b, s, n, m, f)
+
+#define XDL_BUG(msg) BUG(msg)
+
+#endif
Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help