Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Problem with line endings in new IndexDiff Implementation

On Thu, Aug 5, 2010 at 5:34 AM, Baumgart, Jens <jens.baumgart@xxxxxxx> wrote:
> Given a repo with files with UNIX line endings.
> The working tree contains the same files with Windows line endings
> Now the old Implementation of IndexDiff:
> if (indexEntry.isModified(root, true)) {
> returns false for isModified.
> The new implementation says that the files in Index and Working Tree differ:
> if (!dirCacheIterator.idEqual(workingTreeIterator)) {
>         // in index, in workdir, content differs => modified
>         modified.add(dirCacheIterator.getEntryPathString());
> What is the expected behaviour?
> Did I use the wrong method for comparing index and workdir?

No, I think the new code is more correct than the old code.

When the files are converted on checkout from LF to CRLF the size in
the index should be the size of the file in the working tree, while
the ObjectId in the index should be the ObjectId with LFs and not
CRLFs.  IIRC the old implementation was looking only at the last
modified time and may not have checked the sizes, so it didn't care
they were different.  This lead us to conclude the file was unmodified
only because the timestamp matched.  Now we are also checking sizes,
and if the size in the index is from the LF variant of the file, its
not going to match.

Also you need to make the working tree
iterator perform CRLF -> LF conversion on the fly during ObjectId
compare.  So of course they are wrong right now when the file has
CRLFs and the repository has LFs.

Am I right that the length in the index is of the LF variant of the
file, but the working file itself is actually bigger because it has


Back to the top