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

Re: [PATCH 3/9] diff: avoid generating unused hunk header lines

From
Jeff King <peff@peff.net>
Date
Nov 2, 2018, 20:15 UTC
Message-ID
<20181102201549.GA17228@sigill.intra.peff.net>
In-Reply-To
<CAGZ79kZb7kMhkE=EWRtR8tpkQCY3v8rWugHvq24TFGHpBxmygw@mail.gmail.com>
On Fri, Nov 02, 2018 at 12:50:05PM -0700, Stefan Beller wrote:
Show 12 quoted lines
> > +/*
> > + * Can be used as a no-op hunk_fn for xdi_diff_outf(), since a NULL
> > + * one just sends the hunk line to the line_fn callback).
> > + */
> > +void discard_hunk_line(void *, long, long, long, long, const char *, long);
> 
> Recently we had the discussion on style and naming things.
> On the one hand I don't know what these 4 different longs do,
> so I'd wish for some descriptive variable names in here.
> On the other hand the docs explain clearly why I don't need
> to care (a no-op ignores all of the parameters, no need
> to take care of their order)

Right, I actually did have the same thought while writing it. And ended up following that line of reasoning (since it's just a placeholder, it doesn't matter). But I'm not opposed to putting in the names.

> So to revive that discussion, I would strongly prefer
> to have *some* names there, for the sake of a
> simply described coding style without many exceptions
> (especially those exceptions that rely on judgement).
Fair enough.

Squashable patch is below; it goes on 34c829621e (diff: avoid generating unused hunk header lines, 2018-11-02).

Junio, let me know if you'd prefer a re-send of the series, but it doesn't look necessary otherwise (so far).

> Apart from that, I read the whole series, and found
> it a pleasant read.
Thanks!
diff --git a/xdiff-interface.h b/xdiff-interface.h
index 7b0ccbdd1d..8af245eed9 100644
--- a/xdiff-interface.h
+++ b/xdiff-interface.h
@@ -39,7 +39,9 @@ extern int git_xmerge_style;
  * Can be used as a no-op hunk_fn for xdi_diff_outf(), since a NULL
  * one just sends the hunk line to the line_fn callback).
  */
-void discard_hunk_line(void *, long, long, long, long, const char *, long);
+void discard_hunk_line(void *priv,
+		       long ob, long on, long nb, long nn,
+		       const char *func, long funclen);
 
 /*
  * Compare the strings l1 with l2 which are of size s1 and s2 respectively.

-Peff
Previous: Stefan BellerNext: Junio C Hamano
Message 6 of 14 in “saner xdiff hunk callbacks”
  1. 0/9 saner xdiff hunk callbacksJeff King, Nov 2, 2018
  2. 1/9 xdiff: provide a separate emit callback for hunksJeff King, Nov 2, 2018
  3. 2/9 xdiff-interface: provide a separate consume callback for hunksJeff King, Nov 2, 2018
  4. 3/9 diff: avoid generating unused hunk header linesJeff King, Nov 2, 2018
  5. Stefan BellerNov 2, 2018
  6. Jeff KingNov 2, 2018
  7. Junio C HamanoNov 3, 2018
  8. 4/9 diff: discard hunk headers for patch-ids earlierJeff King, Nov 2, 2018
  9. 5/9 diff: use hunk callback for word-diffJeff King, Nov 2, 2018
  10. 6/9 combine-diff: use an xdiff hunk callbackJeff King, Nov 2, 2018
  11. 7/9 diff: convert --check to use a hunk callbackJeff King, Nov 2, 2018
  12. 8/9 range-diff: use a hunk callbackJeff King, Nov 2, 2018
  13. 9/9 xdiff-interface: drop parse_hunk_header()Jeff King, Nov 2, 2018
  14. Junio C HamanoNov 2, 2018

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.