git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bdowning@lavos.net (Brian Downing)
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] Make xdiff_outf_{init,release} interface
Date: Wed, 13 Aug 2008 21:06:14 -0500	[thread overview]
Message-ID: <20080814020614.GD4396@lavos.net> (raw)
In-Reply-To: <7vljz0iftm.fsf@gitster.siamese.dyndns.org>

On Wed, Aug 13, 2008 at 05:46:29PM -0700, Junio C Hamano wrote:
> Brian Downing <bdowning@lavos.net> writes:
> > @@ -103,6 +110,10 @@ int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
> >  	return 0;
> >  }
> >  
> > +void xdiff_outf_release(void *priv_)
> > +{
> > +}
> > +
> 
> It might make it more clear to have this function take a pointer to
> "struct xdiff_emit_state", which is always the first member of the
> callback private data structure.

That makes the call sites (slightly) more complicated, in that instead
of:
	xdiff_outf_release(&state);
you'd want:
	xdiff_outf_release(&state.xm);

That was not the typical usage before, in that it said "ecb.priv =
&state" rather than "ecb.priv = &state.xm", and I used the void *
argument to mirror that, but I can change it if it'd be preferable.
 
> Although I wish xdi_diff() could do the necessary clean-up immediately
> before it returns (so that the caller did not have to do anything
> special), it is not possible to do so cleanly, because there are
> "outf" implementations other than xdiff_outf that do not even use
> "struct xdiff_emit_state" in their callbacks.  So I think your patch
> makes sense.

Well, I could do something like:

	if (xecb->outf == xdiff_outf)
		/* xdiff_outf cleanup */

at the end of xdi_diff, but that's... kind of horrible I think.

For that matter, I could just make an xdi_outf_diff function that would
take the state in addition to the other xdi_diff arguments and go ahead
and set it up, do the diff, and tear it down in one step.  Maybe that
would be better if it works for everywhere this style of diff needs to
be called.

Another question:  should I go ahead and make xdiff_outf itself static?

-bcd

  reply	other threads:[~2008-08-14  2:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13  7:05 [PATCH 1/2] Make xdiff_outf_{init,release} interface Brian Downing
2008-08-14  0:46 ` Junio C Hamano
2008-08-14  2:06   ` Brian Downing [this message]
2008-08-14  2:13     ` Junio C Hamano
2008-08-14  5:13       ` [PATCHv2 1/2] Make xdi_diff_outf interface for running xdiff_outf diffs Brian Downing
2008-08-14  5:13         ` [PATCHv2 2/2] Use strbuf for struct xdiff_emit_state's remainder Brian Downing
2008-08-14  5:31         ` [PATCHv2 1/2] Make xdi_diff_outf interface for running xdiff_outf diffs Brian Downing
2008-08-14  5:36           ` [PATCHv3 " Brian Downing
2008-08-14  5:36             ` [PATCHv3 2/2] Use strbuf for struct xdiff_emit_state's remainder Brian Downing
2008-08-14  6:18             ` [PATCHv3 1/2] Make xdi_diff_outf interface for running xdiff_outf diffs Junio C Hamano
2008-08-14  6:34               ` Brian Downing
2008-08-21  3:37               ` Brian Downing
2008-08-21  5:24                 ` Junio C Hamano
2008-08-21  6:29                   ` Brian Downing

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=20080814020614.GD4396@lavos.net \
    --to=bdowning@lavos.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).