git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: phillip.wood@dunelm.org.uk,
	"Edward Thomson" <ethomson@edwardthomson.com>,
	git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH v2 1/1] xdiff: provide indirection to git functions
Date: Fri, 25 Feb 2022 10:24:14 -0800	[thread overview]
Message-ID: <xmqqo82udctt.fsf@gitster.g> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.2202251639590.11118@tvgsbejvaqbjf.bet> (Johannes Schindelin's message of "Fri, 25 Feb 2022 16:41:57 +0100 (CET)")

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi,
>
> On Tue, 22 Feb 2022, Phillip Wood wrote:
>
>> On 17/02/2022 22:54, Edward Thomson wrote:
>> > 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.
>>
>> The changes since V1 look good,
>
> Indeed. This is the range-diff:
>
> -- snip --
> 1:  52c8f141cbe1 ! 1:  e05e9b5e2f27 xdiff: provide indirection to git functions
>     @@ xdiff/git-xdiff.h (new)
>      +#ifndef GIT_XDIFF_H
>      +#define GIT_XDIFF_H
>      +
>     ++#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)
>     @@ xdiff/xdiffi.c: static void xdl_mark_ignorable_lines(xdchange_t *xscr, xdfenv_t
>
>       ## xdiff/xinclude.h ##
>      @@
>     + #if !defined(XINCLUDE_H)
>       #define XINCLUDE_H
>
>     - #include "git-compat-util.h"
>     +-#include "git-compat-util.h"
>      +#include "git-xdiff.h"
>       #include "xmacros.h"
>       #include "xdiff.h"
>       #include "xtypes.h"
>     -@@
>     - #include "xdiffi.h"
>     - #include "xemit.h"
>     +
>     + ## xdiff/xmerge.c ##
>     +@@ xdiff/xmerge.c: static int xdl_cleanup_merge(xdmerge_t *c)
>     + 		if (c->mode == 0)
>     + 			count++;
>     + 		next_c = c->next;
>     +-		free(c);
>     ++		xdl_free(c);
>     + 	}
>     + 	return count;
>     + }
>     +@@ xdiff/xmerge.c: static void xdl_merge_two_conflicts(xdmerge_t *m)
>     + 	m->chg1 = next_m->i1 + next_m->chg1 - m->i1;
>     + 	m->chg2 = next_m->i2 + next_m->chg2 - m->i2;
>     + 	m->next = next_m->next;
>     +-	free(next_m);
>     ++	xdl_free(next_m);
>     + }
>
>     --
>     - #endif /* #if !defined(XINCLUDE_H) */
>     + /*
> -- snap --
>
> My ACK from
> https://lore.kernel.org/git/nycvar.QRO.7.76.6.2202171644090.348@tvgsbejvaqbjf.bet/
> still holds. Junio could you please add it before merging it down to
> `next`?

Not so fast.  I still do not see a strong reason to support
xdl_malloc() and other wrappers.

Is the expectation for other projects when using the unified code,
they do not use xdiff/git-xdiff.h and instead add
xdiff/frotz-xdiff.h that defines xdl_malloc() and friends with the
infrastructure they provide as part of the Frotz project (and the
Xyzzy project would do the same with xdiff/xyzzy-xdiff.h header for
them), making "git" the first among equal other consumers?

If that is the direction this indirection is aiming for, stating it
clearly may be a start of a not-so-bad justification, but then the
hardcoded inclusion of "git-xdiff.h" in xdiff/xinclude.h still
contradicts with it, which may want to be fixed.



  reply	other threads:[~2022-02-25 18:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 22:52 [PATCH v2 0/1] xdiff: provide indirection to git functions Edward Thomson
2022-02-17 22:54 ` [PATCH v2 1/1] " Edward Thomson
2022-02-22 11:14   ` Phillip Wood
2022-02-25 15:41     ` Johannes Schindelin
2022-02-25 18:24       ` Junio C Hamano [this message]
2022-02-25 18:38         ` Edward Thomson
2022-02-25 18:58           ` Junio C Hamano
2022-02-25 19:03   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqo82udctt.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=ethomson@edwardthomson.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).