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

Re: [PATCH] apply: reallocate the postimage buffer when needed

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 11, 2012, 18:43 UTC
Message-ID
<7v8vj7x9jr.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1331475857-15169-1-git-send-email-cmn@elego.de>
Carlos Martín Nieto <cmn@elego.de> writes:
> Blame says Junio and Giuseppe were the last ones to touch this part of
> the code, so there you go.
Whatever you do in your fix, this comment block needs to be updated:
	/*
	 * Adjust the common context lines in postimage. This can be
	 * done in-place when we are just doing whitespace fixing,
	 * which does not make the string grow, but needs a new buffer
	 * when ignoring whitespace causes the update, since in this case
	 * we could have e.g. tabs converted to multiple spaces.
	 * We trust the caller to tell us if the update can be done
	 * in place (postlen==0) or not.
	 */

The second sentence used to be true for a long time (if you indented your line with too many spaces, we removed them and replaced with fewer number of tabs; if you had spaces before a tab, we removed them; if you added unnecessary whitespaces at the end, we removed them), but ceased to be so when Python style "indent must be spaces" was added.

So I think this either always needs to re-allocate, or the caller has to tell it by other means than "!postlen" the need for reallocation.

I wasn't involved in the "apply while ignoring whitespace differences", so Giuseppe may be able to notice other mode of beakages in this and fuzzy_matchlines() function. The commit to be stared at is 86c91f9 (git apply: option to ignore whitespace differences, 2009-08-04).

Thanks.
Previous: Carlos Martín NietoNext: Junio C Hamano
Message 2 of 4 in “apply: reallocate the postimage buffer when needed”
  1. apply: reallocate the postimage buffer when neededCarlos Martín Nieto, Mar 11, 2012
  2. Junio C HamanoMar 11, 2012
  3. Junio C HamanoMar 11, 2012
  4. Junio C HamanoMar 12, 2012

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.