libgit2/libgit2 — pull request #1254 by ethomson (2013-01-17 21:14:49+00:00)
Title: cache should contain on-disk (filtered) file size

The cache should contain the on-disk file size. If we apply a filter, we should update the index's size. Using `\n` -> `\r\n` conversion via `core.autocrlf=true` on a file containing only `\n`'s:

With core git:

C:\Temp> git clone https://github.com/ethomson/crlf
Cloning into 'crlf'...
remote: Counting objects: 35, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 35 (delta 2), reused 35 (delta 2)
Unpacking objects: 100% (35/35), done.
C:\Temp> cd crlf
C:\Temp\crlf> git status
# On branch master
nothing to commit, working directory clean
C:\Temp\crlf> hexdump all-lf
00000000 6c 66 0d 0a 6c 66 0d 0a 6c 66 0d 0a 6c 66 0d 0a [lf.. lf.. lf.. lf..]
00000001 6c 66 0d 0a [lf.. ]
C:\Temp\crlf> git ls-files --stage --debug all-lf
100644 799770d1cff46753a57db7a066159b5610da6e3a 0 all-lf
ctime: 1358454081:0
mtime: 1358454081:0
dev: 0 ino: 0
uid: 0 gid: 0
size: 20 flags: 0

With libgit2:

C:\Temp> cgit2 clone https://github.com/ethomson/crlf crlf
....
C:\Temp> cd crlf
C:\Temp> git status all-lf
# On branch master
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: all-lf
#
no changes added to commit (use "git add" and/or "git commit -a")

C:\Temp> hexdump all-lf
00000000 6c 66 0d 0a 6c 66 0d 0a 6c 66 0d 0a 6c 66 0d 0a [lf..lf..lf..lf..]
00000001 6c 66 0d 0a [lf.. ]
C:\Temp\crlf> git ls-files --stage --debug all-lf
100644 799770d1cff46753a57db7a066159b5610da6e3a 0 all-lf
ctime: 1358456764:0
mtime: 1358456764:0
dev: 0 ino: 0
uid: 0 gid: 0
size: 15 flags: 0