diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -993,8 +993,10 @@ # if file data starts with '\1\n', empty metadata block is # prepended, which adds 4 bytes to filelog.size(). return self._filelog.cmp(self._filenode, fctx.data()) - if self.size() == fctx.size(): + if self.size() == fctx.size() or self.flags() == b'l': # size() matches: need to compare content + # issue6456: Always compare symlinks because size can represent + # encrypted string for EXT-4 encryption(fscrypt). return self._filelog.cmp(self._filenode, fctx.data()) # size() differs diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1270,6 +1270,7 @@ if not st and state in b"nma": dadd(fn) elif state == b'n': + islink = (stat.S_IFLNK == (st.st_mode & stat.S_IFLNK)) if ( size >= 0 and ( @@ -1279,7 +1280,12 @@ or size == -2 # other parent or fn in copymap ): - madd(fn) + if (islink): + # issue6456: Size returned may be longer due to + # encryption on EXT-4 fscrypt, undecided. + ladd(fn) + else: + madd(fn) elif ( time != st[stat.ST_MTIME] and time != st[stat.ST_MTIME] & _rangemask