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

Re: [BUG] git apply: pure rename followed by edit fails with core.fileMode=false

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 6, 2026, 20:36 UTC
Message-ID
<xmqqwlqpg0js.fsf@gitster.g>
In-Reply-To
<20261106181145.1070831-1-aniketgupta3001@gmail.com>
Aniket Gupta <aniketgupta3001@gmail.com> writes:
Show 5 quoted lines
> I was able to repro this. One thing I noticed: taking the whole mode
> from patch->old_mode also takes the file type, so the "wrong type"
> check can no longer fail. With a pure rename of a regular file followed
> by a hand-made patch that says it is a symlink, core.fileMode=true
> rejects it but =false applies it and turns the file into a symlink.

Why does the input patch talk about exactly the same path twice in the first place, though? Are we talking about a valid patch input, or are we bending the tool to cope better with corrupt input?

> Would S_IFREG | (patch->old_mode & 07777) be better? That passed your
> test and the other apply tests for me.
Would it work equally well when applying the patch in reverse?
Previous: Aniket GuptaNext: Aniket Gupta
Message 3 of 8 in “[BUG] git apply: pure rename followed by edit fails with core.fileMode=false”
  1. Hannes Brandstätter-MüllerOct 23, 2026
  2. Aniket GuptaNov 6, 2026
  3. Junio C HamanoNov 6, 2026
  4. Aniket GuptaNov 7, 2026
  5. Junio C HamanoNov 7, 2026
  6. Aniket GuptaNov 7, 2026
  7. Patrick SteinhardtNov 9, 2026
  8. Aniket GuptaNov 9, 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.