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

Re: [nit] diff func headers ignore context

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2011, 19:01 UTC
Message-ID
<7vpqj3t0cz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110913220421.GA24549@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 19 quoted lines
> On Tue, Sep 13, 2011 at 05:58:25PM -0400, Jeff King wrote:
>
>> @@ -609,26 +610,23 @@ int finish_async(struct async *async)
>>  int run_hook(const char *index_file, const char *name, ...)
>>  {
>>  	struct child_process hook;
>> -	const char **argv = NULL, *env[2];
>> +	struct argv_array argv = ARGV_ARRAY_INIT;
>
> I find this diff function header pretty confusing. Of course we're not
> in finish_async, as you can see by the fact that the context contains
> the start of run_hook.
>
> I don't think this is something that can be solved with xfuncname
> config; we would have to teach xdiff to look at context lines when
> picking a header line.
>
> Am I the only one who finds this confusing? Can anyone think of a reason
> to keep showing finish_async in this example?

Would this be sufficient? Instead of looking for the first line that matches the "beginning" pattern going backwards starting from one line before the displayed context, we start our examination at the first line shown in the context.

 xdiff/xemit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 277e2ee..5f9c0e0 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -131,7 +131,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 
 		if (xecfg->flags & XDL_EMIT_FUNCNAMES) {
 			long l;
-			for (l = s1 - 1; l >= 0 && l > funclineprev; l--) {
+			for (l = s1; l >= 0 && l > funclineprev; l--) {
 				const char *rec;
 				long reclen = xdl_get_rec(&xe->xdf1, l, &rec);
 				long newfunclen = ff(rec, reclen, funcbuf,
Previous: Andreas EricssonNext: Junio C Hamano
Message 15 of 18 in “create argv_array API”
  1. 0/7 create argv_array APIJeff King, Sep 13, 2011
  2. 1/7 add sha1_array API docsJeff King, Sep 13, 2011
  3. 2/7 quote.h: fix bogus commentJeff King, Sep 13, 2011
  4. 3/7 refactor argv_array into generic codeJeff King, Sep 13, 2011
  5. Christian CouderSep 14, 2011
  6. Jeff KingSep 14, 2011
  7. Junio C HamanoSep 14, 2011
  8. Junio C HamanoSep 14, 2011
  9. 4/7 quote: provide sq_dequote_to_argv_arrayJeff King, Sep 13, 2011
  10. 5/7 bisect: use argv_array APIJeff King, Sep 13, 2011
  11. 6/7 checkout: use argv_array APIJeff King, Sep 13, 2011
  12. 7/7 run_hook: use argv_array APIJeff King, Sep 13, 2011
  13. [nit] diff func headers ignore contextJeff King, Sep 13, 2011
  14. Andreas EricssonSep 14, 2011
  15. Junio C HamanoSep 14, 2011
  16. Junio C HamanoSep 14, 2011
  17. Jeff KingSep 14, 2011
  18. Junio C HamanoSep 14, 2011

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.