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

Re: [PATCH] date: remove approxidate_relative()

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 10, 2023, 21:05 UTC
Message-ID
<xmqqy1mzcus6.fsf@gitster.g>
In-Reply-To
<20230410202536.GE104097@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> 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.

"-U16" extends the context lines in both directions by the same number of lines, but most likely you need to extend asymmetrically. In René's patch, for example, much of the body of approxidate_str() is visible in the precontext of the hunk to remove approxidate_relative(), but the body of that function is irrelevant. What he wanted to show was the body of approxidate_careful() and the size of that function is where the -U16 came from.

Instead, imagine --extra-context='<range>:<path>' were the way to tell Git to include the specified range of lines in the post context even though they may not have been modified. Then René's patch could have been produced with

    $ git format-patch -1 \
      --extra-context='/^timestamp_t approxidate_careful/,/^}$/:date.c'

and would have shown 3 lines of precontext before the removed approxidate_relative(), plus the unchanged approxidate_careful() function in full in the postcontext.

Previous: Jeff KingNext: Jeff King
Message 6 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.