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

Re: [PATCH] apply: avoid leaking abandoned git-header state

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2026, 20:31 UTC
Message-ID
<xmqqtsogei9d.fsf@gitster.g>
In-Reply-To
<20260702041759.51572-1-zhihao.yao@njit.edu>
Zephyr Yao <zot.zot.yao@gmail.com> writes:
Show 10 quoted lines
> When find_header() sees a "diff --git" line, it calls
> parse_git_diff_header() to parse the git-style extended header. That parser
> updates the caller's struct patch as it goes, filling in the default name,
> old/new names, and new/delete state.
>
> But not every "diff --git" line found while scanning is ultimately accepted
> as the patch header. If parse_git_diff_header() returns a length that covers
> only the "diff --git" line, find_header() continues scanning for another
> header. In that case the partially parsed git-header state must not interfere
> with the later traditional "---" / "+++" header.

This patch has gathered no response. Perhaps the e-mail received no reply because it was sent in early July around the holiday, or perhaps nobody was interested in the topic. In any case, I am cleaning up the "What's cooking" report and noticed that this has been in the "Needs review" state for a long time.

So I took a look.

These cross checks are primarily sanity checks. Having the parser notice a discrepancy and abort is a good thing. The user is supposed to inspect the situation and fix a malformed patch (such as one containing a stray 'diff --git' header unrelated to the actual patch).

So I do not think we want to apply this patch.
Thanks.
Previous: Zephyr Yao
Message 2 of 2 in “apply: avoid leaking abandoned git-header state”
  1. apply: avoid leaking abandoned git-header stateZephyr Yao, Jul 2, 2026
  2. Junio C HamanoAug 26, 2026

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.