summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ccd0a8)
raw | patch | inline | side by side (parent: 9ccd0a8)
author | Brian Downing <bdowning@lavos.net> | |
Sat, 25 Oct 2008 13:30:54 +0000 (15:30 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 25 Oct 2008 19:09:31 +0000 (12:09 -0700) |
For some users (e.g. git blame), getting textual patch output is just
extra work, as they can get all the information they need from the low-
level diff structures. Allow for an alternate low-level emit function
to be defined to allow bypassing the textual patch generation; set
xemitconf_t's emit_func member to enable this.
The (void (*)()) type is pretty ugly, but the alternative would be to
include most of the private xdiff headers in xdiff.h to get the types
required for the "proper" function prototype. Also, a (void *) won't
work, as ANSI C doesn't allow a function pointer to be cast to an
object pointer.
Signed-off-by: Brian Downing <bdowning@lavos.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
extra work, as they can get all the information they need from the low-
level diff structures. Allow for an alternate low-level emit function
to be defined to allow bypassing the textual patch generation; set
xemitconf_t's emit_func member to enable this.
The (void (*)()) type is pretty ugly, but the alternative would be to
include most of the private xdiff headers in xdiff.h to get the types
required for the "proper" function prototype. Also, a (void *) won't
work, as ANSI C doesn't allow a function pointer to be cast to an
object pointer.
Signed-off-by: Brian Downing <bdowning@lavos.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff/xdiff.h | patch | blob | history | |
xdiff/xdiffi.c | patch | blob | history | |
xdiff/xemit.c | patch | blob | history | |
xdiff/xemit.h | patch | blob | history |
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index deebe02cd3489ef3ce94b407ff9c3de4c21a0eb1..84fff583e2a6e3411da4260b9af98043fade1e49 100644 (file)
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
unsigned long flags;
find_func_t find_func;
void *find_func_priv;
+ void (*emit_func)();
} xdemitconf_t;
typedef struct s_bdiffparam {
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 1bad8462fb32cffdc9ff20a278d513e7a444b257..9d0324a38c2a1974648e67161fa0ed1b0f811233 100644 (file)
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
xdemitconf_t const *xecfg, xdemitcb_t *ecb) {
xdchange_t *xscr;
xdfenv_t xe;
+ emit_func_t ef = xecfg->emit_func ?
+ (emit_func_t)xecfg->emit_func : xdl_emit_diff;
if (xdl_do_diff(mf1, mf2, xpp, &xe) < 0) {
return -1;
}
if (xscr) {
- if (xdl_emit_diff(&xe, xscr, ecb, xecfg) < 0) {
+ if (ef(&xe, xscr, ecb, xecfg) < 0) {
xdl_free_script(xscr);
xdl_free_env(&xe);
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index d3d9c845c6420e4881636d779c7029f900a0b067..4625c1b4215231dc343478b2f4f7b4bfccf2c766 100644 (file)
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec);
static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb);
-static xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg);
* Starting at the passed change atom, find the latest change atom to be included
* inside the differential hunk according to the specified configuration.
*/
-static xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg) {
+xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg) {
xdchange_t *xch, *xchp;
for (xchp = xscr, xch = xscr->next; xch; xchp = xch, xch = xch->next)
diff --git a/xdiff/xemit.h b/xdiff/xemit.h
index 440a7390fa4abb0411c336cfba616e3229484e86..c2e2e830273782dc597606ddbb0401c04dce8f8f 100644 (file)
--- a/xdiff/xemit.h
+++ b/xdiff/xemit.h
#define XEMIT_H
+typedef int (*emit_func_t)(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
+ xdemitconf_t const *xecfg);
+xdchange_t *xdl_get_hunk(xdchange_t *xscr, xdemitconf_t const *xecfg);
int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
xdemitconf_t const *xecfg);