git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Levedahl <mdl123@verizon.net>
To: git@vger.kernel.org
Cc: Mark Levedahl <mlevedahl@verizon.net>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: autoCRLF, git status, git-gui, what is the desired behavior?
Date: Sun, 25 Feb 2007 17:20:50 -0500	[thread overview]
Message-ID: <45E20BC2.3000305@verizon.net> (raw)
In-Reply-To: <7v649qrkzg.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano wrote:
> Mark Levedahl <mlevedahl@verizon.net> writes:
> 
>> ... Is it the case that
>> the size info stored in the index reflects the size of the blob rather
>> than of the working copy?
> 
> The size field among other fields is to cache the last lstat(2)
> information so that later "is the path modified?" question can
> be answered efficiently.  So the size should in general match
> both blob and filesystem but on CRLF filesystems it is compared
> against and updated with the data from the filesystem.  There
> could be a subtle bug that when updating an index entry we might
> be incorrectly storing the size of the blob, but I haven't
> checked.
> 
> 
> 
I instrumented read-cache.c with:

@@ -818,6 +822,8 @@ int read_cache_from(const char *path)
         struct cache_entry *ce = (struct cache_entry *) ((char *) 
cache_mmap + offset);
         offset = offset + ce_size(ce);
         active_cache[i] = ce;
+       printf("name: %s\n", ce->name);
+       printf("size: %u\n", ntohl(ce->ce_size)
     }
     index_file_timestamp = st.st_mtime;
     while (offset <= cache_mmap_size - 20 - 8) {

And I get, post commit:
name: foo
size: 21452

$ git-update-index
$ git-runstatus
...
name: foo
size: 20517
...

Note:  foo's size with lf endings is 20517
                   with crlf endings is 21452

So, what I think is happening:

I add a file with crlf endings: it gets converted to lf, but the file 
size with crlf is saved in the index.

Post commit, the file is replaced with lf endings in the working 
directory and now has size 205167. However, the index reflects the 
pre-converted file with crlf endings, not the post-converted with lf 
endings.

Remember: I have core.autocrlf=input, so all files have lf on output. 
Apparently the working file is updated by this process. The problem is 
the index is not updated to reflect that.

Mark

  reply	other threads:[~2007-02-25 22:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-25 19:33 autoCRLF, git status, git-gui, what is the desired behavior? Mark Levedahl
2007-02-25 19:54 ` Junio C Hamano
2007-02-25 20:28   ` Junio C Hamano
2007-02-25 21:14     ` Mark Levedahl
2007-02-25 21:22       ` Junio C Hamano
2007-02-25 22:20         ` Mark Levedahl [this message]
2007-02-25 23:55           ` Mark Levedahl
2007-02-25 20:51   ` Mark Levedahl
2007-02-26  2:06     ` Shawn O. Pearce
2007-02-26  2:45       ` Junio C Hamano
2007-02-26 15:54         ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45E20BC2.3000305@verizon.net \
    --to=mdl123@verizon.net \
    --cc=git@vger.kernel.org \
    --cc=mlevedahl@verizon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).