Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Quick question about WorkingTreeIterator::contentCheck

On Tue, Mar 10, 2020 at 3:34 PM Peter Hull <peterhull90@xxxxxxxxx> wrote:
I was just looking at the source for
org.eclipse.jgit.treewalk.WorkingTreeIterator (via the github mirror),
and I noticed something I thought was strange in function contentCheck
        if (mode == FileMode.SYMLINK.getBits()) {
            return !new File(readSymlinkTarget(current())).equals(
                    new File(readContentAsNormalizedString(entry, reader)));
The functions readSymlinkTarget and readContentAsNormalizedString both
return strings which are the contents of their respective files. But
the constructor should be taking a path name argument.
Have I understood correctly?
Is it right to construct File objects like this?

- readSymlinkTarget reads the target path of a symlink from the given (current()) WorkingTreeIterator entry
- readContentAsNormalizedString reads the path of an entry in the DirCache (JGit's implementation of the git index)

This means both call the File constructor with a file path which is what it expects.


Back to the top