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

Re: [PATCH] Fix incorrect diff of a link -> file change if core.filemode = false.

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Feb 16, 2007, 23:30 UTC
Message-ID
<200702170030.04014.johannes.sixt@telecom.at>
In-Reply-To
<7vejop1ysu.fsf@assigned-by-dhcp.cox.net>
On Saturday 17 February 2007 00:13, Junio C Hamano wrote:
Show 20 quoted lines
> Johannes Sixt <johannes.sixt@telecom.at> writes:
> > After this sequence:
> >
> > $ ln -s foo A
> > $ git add A
> > $ git commit -m link
> > $ rm A && echo bar > A
> >
> > the working copy contains a regular file A but HEAD contains A as a link.
> >
> > Normally, at this point 'git diff HEAD' displays this change as a removal
> > of the link followed by an addition of a new file. But in a repository
> > where core.filemode is false this is displayed as a modification of the
> > link. The reason is that the check when the cached mode is allowed to
> > override the file's actual mode is not strict enough.
> >
> > Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
>
> I do not follow.  core.filemode aka trust_executable_bit is
> about executable bit and not symlink.

Correct. But the breakage is still there. As you recall, the properties S_IFREG and S_IFLNK are recorded in the st_mode, and the line of code that I fixed trusts the index in too many cases, and copies the index's S_IFLNK over the the stat() result, which said S_IFREG. So the diff engine loses the information that it is should diff against a regular file, and thinks that the working copy is a symlink.

Please change the last sentence of the commit message, which hopefully makes the issue a bit clearer:

The fix is that the cached mode must only be allowed to override the file's actual mode (which includes the type information) if _both_ the working tree entry and the cached entry are regular files.

-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “Fix incorrect diff of a link -> file change if core.filemode = false.”
  1. Fix incorrect diff of a link -> file change if core.filemode = false.Johannes Sixt, Feb 16, 2007
  2. Junio C HamanoFeb 16, 2007
  3. Johannes SixtFeb 16, 2007
  4. Junio C HamanoFeb 17, 2007
  5. Do not take mode bits from index after type change.Junio C Hamano, Feb 17, 2007
  6. Johannes SixtFeb 17, 2007
  7. Junio C HamanoFeb 17, 2007

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.