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

Re: [PATCH] date: remove approxidate_relative()

From
Jeff King <peff@peff.net>
Date
Apr 10, 2023, 20:25 UTC
Message-ID
<20230410202536.GE104097@coredump.intra.peff.net>
In-Reply-To
<xmqqjzyjemji.fsf@gitster.g>
On Mon, Apr 10, 2023 at 09:20:49AM -0700, Junio C Hamano wrote:
Show 16 quoted lines
> Perhaps
> 
> 	$ git -c format-patch.date.c.context=16 format-patch -1
> 
> would be a workable idea?  I do not think it makes any sense to say
> "when taking a diff for this path, always use 16 lines of context"
> so it should not be stored in a file to be used every time, like
> 
> 	[format-patch "date.c"] context = 16
> 
> and it makes even less sense to say that all project participants
> should use this context, always, so making it an attribute would be
> even less appropriate.
> 
> But this was the easiest way to prototype ;-)  If this turns out to
> be useful, the real version should probably be done by:

Cute. It feels like this only goes half-way, though. You really want per-hunk configurable context. This particular patch was just lucky that there was only one hunk in the date.c file.

I'm not sure of the least-confusing way to address a single hunk, though (by line number is one option, by hunk-number within the patch is another). I suspect the best workflow for a user would be to interactively say "show me more context for this hunk". Some viewers have support for that (e.g., GitHub's web view of a diff). But handling that for a one-shot CLI program is tricky, not to mention then feeding it back to format-patch to generate the output you want to send. :)

-Peff
Previous: Junio C HamanoNext: René Scharfe
Message 3 of 9 in “date: remove approxidate_relative()”
  1. date: remove approxidate_relative()René Scharfe, Apr 8, 2023
  2. Junio C HamanoApr 10, 2023
  3. Jeff KingApr 10, 2023
  4. René ScharfeApr 10, 2023
  5. Jeff KingApr 11, 2023
  6. Junio C HamanoApr 10, 2023
  7. Jeff KingApr 11, 2023
  8. Junio C HamanoApr 11, 2023
  9. Jeff KingApr 12, 2023

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.