git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Does changing filename case breaks git's rename heuristic?

From
Dan Loewenherz <dloewenherz@gmail.com>
Date
Aug 27, 2010, 14:52 UTC
Message-ID
<AANLkTikN_PbNNH2f4zWuk1FH+LgpKzkoZ6mYOdT9ANBj@mail.gmail.com>
In-Reply-To
<4C777090.2000107@drmicha.warpmail.net>

On Fri, Aug 27, 2010 at 1:00 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 20 quoted lines
> Dan Loewenherz venit, vidit, dixit 27.08.2010 06:57:
>> Hi all,
>>
>> I may be mistaking a design decision as a bug, but I wanted to throw
>> this out to the list to make sure. I think that re-enacting it will be
>> the best way to explain it.
>>
>> $ mkdir test
>> $ cd test
>> $ git init
>> $ cat > readme
>> This is a test file.
>> ^D
>> $ git commit -am "first commit"
>> [master (root-commit) fae0d05] first commit
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> ? You have not added any file, so git won't commit anything (not even
> with -a). The above can't be a complete transcription. I assume you've
> added readme with the content above.
Yep, that was my mistake. I left out 'git add readme'.
Show 8 quoted lines
>
>>
>> For personal reasons, I now want readme to be uppercase.
>>
>> $ mv readme README
>
> Here's where using "git mv" would have been the easier choice, followed
> by commit.

I agree. The instance where this actually occurred was that I had received an updated binary file to put into my repository. icon.png -> Icon.png. I suppose I could've run 'git mv' but I didn't realize what would happen if I didn't!

Show 7 quoted lines
>
>> $ cat > README
>> This is the revised README.
>
> Renaming and changing the content completely in one step will always
> trip up git's rename detection. You should rename, commit, change,
> commit, unless the change affects a small portion of the file only.
Agreed.
Show 9 quoted lines
>
>> $ git status -sb
>> ## master
>>  M readme
>
> Again, this can't be a complete transcript. The above would lead to
>
>  D readme
> ?? README

This is where I didn't botch up the transcript, and where I was actually surprised at what was going on. I'll insert a full one at the bottom of this email that can actually be run to get the same results.

Show 10 quoted lines
>
>> $ git add README
>> $ git status -sb
>> ## master
>>  M readme
>>
>> At this point, I'm thinking that git is confused. Even though I've
>
> Are you possibly using a case-challenged file system? Is this maybe on a
> Mac with HFS or Win with NTFS?
I'm using a Mac with a journaled filesystem and Git version 1.7.2.1.
>
> Michael
>
Transcript
dan ~ $ mkdir test
dan ~ $ cd test/
dan test $ git init
Initialized empty Git repository in /Users/dan/test/.git/
dan test (master #) $ cat > readme
This is a test file.
dan test (master #%) $ git add readme
dan test (master #) $ git ci -m "first commit"
[master (root-commit) 3237fcb] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 readme
dan test (master) $ mv readme README
dan test (master) $ cat > README
This is the revised README.
dan test (master *) $ git s
## master
 M readme
dan test (master *) $ git add README
dan test (master *) $ git s
## master
 M readme
dan test (master *) $ git add readme
dan test (master +) $ git s
## master
M  readme
dan test (master +) $ git ci -m "change filename"
[master 587f3f8] change filename
 1 files changed, 1 insertions(+), 1 deletions(-)
dan test (master) $ git --version
git version 1.7.2.1
Previous: Michael J GruberNext: Michael J Gruber
Message 4 of 8 in “Does changing filename case breaks git's rename heuristic?”
  1. Dan LoewenherzAug 27, 2010
  2. Ramkumar RamachandraAug 27, 2010
  3. Michael J GruberAug 27, 2010
  4. Dan LoewenherzAug 27, 2010
  5. Michael J GruberAug 27, 2010
  6. Stephen BashAug 27, 2010
  7. Jay SoffianAug 27, 2010
  8. Ævar Arnfjörð BjarmasonAug 28, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.