git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] Make xdiff_outf_{init,release} interface

From
Brian Downing <bdowning@lavos.net>
Date
Aug 14, 2008, 02:06 UTC
Message-ID
<20080814020614.GD4396@lavos.net>
In-Reply-To
<7vljz0iftm.fsf@gitster.siamese.dyndns.org>
On Wed, Aug 13, 2008 at 05:46:29PM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> 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.
 
Show 6 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 14 in “Make xdiff_outf_{init,release} interface”
  1. 1/2 Make xdiff_outf_{init,release} interfaceBrian Downing, Aug 13, 2008
  2. Junio C HamanoAug 14, 2008
  3. Brian DowningAug 14, 2008
  4. Junio C HamanoAug 14, 2008
  5. 1/2 Make xdi_diff_outf interface for running xdiff_outf diffsBrian Downing, Aug 14, 2008
  6. 2/2 Use strbuf for struct xdiff_emit_state's remainderBrian Downing, Aug 14, 2008
  7. Brian DowningAug 14, 2008
  8. 1/2 Make xdi_diff_outf interface for running xdiff_outf diffsBrian Downing, Aug 14, 2008
  9. 2/2 Use strbuf for struct xdiff_emit_state's remainderBrian Downing, Aug 14, 2008
  10. Junio C HamanoAug 14, 2008
  11. Brian DowningAug 14, 2008
  12. Brian DowningAug 21, 2008
  13. Junio C HamanoAug 21, 2008
  14. Brian DowningAug 21, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.