# Cloned repository has file changes -> bug?

10 messages from 2018-01-27 to 2018-02-06. Participants: Filip Jorissen, Ævar Arnfjörð Bjarmason, Torsten Bögershausen, brian m. carlson, Duy Nguyen, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/47702

## Filip Jorissen, 2018-01-27 19:35

Subject: Cloned repository has file changes -> bug?
Message-ID: <BCFDB3A3-B515-4932-AC67-F720AEB4B0BE@kuleuven.be>
URL: https://gitlist.dev/e/BCFDB3A3-B515-4932-AC67-F720AEB4B0BE%40kuleuven.be

```
Dear all,

I think our git repository is bugged. The reason why I say this is the following. When cloning the repository, the newly cloned repository immediately has file changes. Steps to reproduce and illustration is at the end of this email. Git checkout does not work to remove the file changes. This behavior seems to be reproducible across multiple computers. Is this a bug? How can I fix the repository?

Thanks in advance for the support!

Filip


MacBook-Pro-van-Filip:git filip$ git clone git@github.com:open-ideas/IDEAS.git
Cloning into 'IDEAS'...
remote: Counting objects: 48419, done.
remote: Compressing objects: 100% (198/198), done.
remote: Total 48419 (delta 134), reused 217 (delta 97), pack-reused 48108
Receiving objects: 100% (48419/48419), 42.32 MiB | 1.81 MiB/s, done.
Resolving deltas: 100% (32847/32847), done.
MacBook-Pro-van-Filip:git filip$ cd IDEAS
MacBook-Pro-van-Filip:IDEAS filip$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
	modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_SaturationPressure.txt

no changes added to commit (use "git add" and/or "git commit -a")

```

## Ævar Arnfjörð Bjarmason, 2018-01-27 19:59

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <87607nvzrd.fsf@evledraar.gmail.com>
URL: https://gitlist.dev/e/87607nvzrd.fsf%40evledraar.gmail.com
In-Reply-To: <BCFDB3A3-B515-4932-AC67-F720AEB4B0BE@kuleuven.be>

```

On Sat, Jan 27 2018, Filip Jorissen jotted:

> I think our git repository is bugged. The reason why I say this is the
> following. When cloning the repository, the newly cloned repository
> immediately has file changes[...].

If you run this:

    git ls-files | tr '[:upper:]' '[:lower:]' | sort | uniq -D | grep '^'

You'll see that the reason is that you have files that differ only in
case.

You are using a Mac, and Macs by default think that files that are
different binary strings are the same file, since they don't consider
case to be relevant. The file FOO, foo and FoO and fOo are all the same
file as far as your Mac is concerned, but would be 4 different files on
Linux.

> How can I fix the repository?

You could check it out on a OS that considers files that differ in case
to be different files, e.g. on Linux, move them around, push it, and new
clones should work on your Mac.

Alternatively I hear that you can create a loopback case-sensitive FS
image on Macs.

```

## Torsten Bögershausen, 2018-01-28 07:57

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <20180128075731.GA17412@tor.lan>
URL: https://gitlist.dev/e/20180128075731.GA17412%40tor.lan
In-Reply-To: <87607nvzrd.fsf@evledraar.gmail.com>

```
On Sat, Jan 27, 2018 at 08:59:50PM +0100, Ævar Arnfjörð Bjarmason wrote:
> 
> On Sat, Jan 27 2018, Filip Jorissen jotted:
> 
> > I think our git repository is bugged. The reason why I say this is the
> > following. When cloning the repository, the newly cloned repository
> > immediately has file changes[...].
> 
> If you run this:
> 
>     git ls-files | tr '[:upper:]' '[:lower:]' | sort | uniq -D | grep '^'
> 
> You'll see that the reason is that you have files that differ only in
> case.
> 
> You are using a Mac, and Macs by default think that files that are
> different binary strings are the same file, since they don't consider
> case to be relevant. The file FOO, foo and FoO and fOo are all the same
> file as far as your Mac is concerned, but would be 4 different files on
> Linux.
> 
> > How can I fix the repository?
> 
> You could check it out on a OS that considers files that differ in case
> to be different files, e.g. on Linux, move them around, push it, and new
> clones should work on your Mac.
> 
> Alternatively I hear that you can create a loopback case-sensitive FS
> image on Macs.

You can even fix the repo locally.
There are 2 files with uppercase/lowercase collisions.
I show you how to fix one off these, the other one goes similar.
After that, do a commit and a push and pull request.



Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_saturationPressure.txt

no changes added to commit (use "git add" and/or "git commit -a")
user@mac:/tmp/IDEAS> git ls-files -s | grep -i IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
100644 f56cfcf14aa4b53dfc5ecfb488366f721c94c8e2 0       IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
100644 e345e1372111d034b4c5a1c75eb791340b93f55e 0       IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
user@mac:/tmp/IDEAS> git mv IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
user@mac:/tmp/IDEAS> git checkout  IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
user@mac:/tmp/IDEAS> git checkout IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
user@mac:/tmp/IDEAS> git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        renamed:    IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt -> IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_saturationPressure.txt

user@mac:/tmp/IDEAS>

```

## brian m. carlson, 2018-01-28 15:28

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <20180128152822.GF431130@genre.crustytoothpaste.net>
URL: https://gitlist.dev/e/20180128152822.GF431130%40genre.crustytoothpaste.net
In-Reply-To: <BCFDB3A3-B515-4932-AC67-F720AEB4B0BE@kuleuven.be>

```
On Sat, Jan 27, 2018 at 07:35:49PM +0000, Filip Jorissen wrote:
> I think our git repository is bugged. The reason why I say this is the following. When cloning the repository, the newly cloned repository immediately has file changes. Steps to reproduce and illustration is at the end of this email. Git checkout does not work to remove the file changes. This behavior seems to be reproducible across multiple computers. Is this a bug? How can I fix the repository?
> 
> Changes not staged for commit:
>   (use "git add <file>..." to update what will be committed)
>   (use "git checkout -- <file>..." to discard changes in working directory)
> 
> 	modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
> 	modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_SaturationPressure.txt

This repository has multiple files that differ only in case.  I take it
from your hostname that you're on a Mac, and by default macOS uses a
case-insensitive file system.

Since the two files aren't identical, one or the other will show as
modified.  You probably want to adjust the repository so that it doesn't
have files differing only in case or use a case-sensitive file system.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

```

## Filip Jorissen, 2018-02-06 13:09

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <CD3563ED-5E0D-4238-A664-4F2335598FE2@kuleuven.be>
URL: https://gitlist.dev/e/CD3563ED-5E0D-4238-A664-4F2335598FE2%40kuleuven.be
In-Reply-To: <20180128075731.GA17412@tor.lan>

```
Hi all,

Thank you for your quick responses. I was able to resolve the problem based on your feedback!

Based on this experience, I would like to suggest that git is somehow able to avoid these problems by doing a case check itself rather than relying on the host OS for this? 

Kind regards!

Filip



> Op 28 jan. 2018, om 08:57 heeft Torsten Bögershausen <tboegi@web.de> het volgende geschreven:
> 
> On Sat, Jan 27, 2018 at 08:59:50PM +0100, Ævar Arnfjörð Bjarmason wrote:
>> 
>> On Sat, Jan 27 2018, Filip Jorissen jotted:
>> 
>>> I think our git repository is bugged. The reason why I say this is the
>>> following. When cloning the repository, the newly cloned repository
>>> immediately has file changes[...].
>> 
>> If you run this:
>> 
>>    git ls-files | tr '[:upper:]' '[:lower:]' | sort | uniq -D | grep '^'
>> 
>> You'll see that the reason is that you have files that differ only in
>> case.
>> 
>> You are using a Mac, and Macs by default think that files that are
>> different binary strings are the same file, since they don't consider
>> case to be relevant. The file FOO, foo and FoO and fOo are all the same
>> file as far as your Mac is concerned, but would be 4 different files on
>> Linux.
>> 
>>> How can I fix the repository?
>> 
>> You could check it out on a OS that considers files that differ in case
>> to be different files, e.g. on Linux, move them around, push it, and new
>> clones should work on your Mac.
>> 
>> Alternatively I hear that you can create a loopback case-sensitive FS
>> image on Macs.
> 
> You can even fix the repo locally.
> There are 2 files with uppercase/lowercase collisions.
> I show you how to fix one off these, the other one goes similar.
> After that, do a commit and a push and pull request.
> 
> 
> 
> Changes not staged for commit:
>  (use "git add <file>..." to update what will be committed)
>  (use "git checkout -- <file>..." to discard changes in working directory)
> 
>        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
>        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_saturationPressure.txt
> 
> no changes added to commit (use "git add" and/or "git commit -a")
> user@mac:/tmp/IDEAS> git ls-files -s | grep -i IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
> 100644 f56cfcf14aa4b53dfc5ecfb488366f721c94c8e2 0       IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
> 100644 e345e1372111d034b4c5a1c75eb791340b93f55e 0       IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
> user@mac:/tmp/IDEAS> git mv IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
> user@mac:/tmp/IDEAS> git checkout  IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
> user@mac:/tmp/IDEAS> git checkout IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
> user@mac:/tmp/IDEAS> git status
> On branch master
> Your branch is up to date with 'origin/master'.
> 
> Changes to be committed:
>  (use "git reset HEAD <file>..." to unstage)
> 
>        renamed:    IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt -> IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
> 
> Changes not staged for commit:
>  (use "git add <file>..." to update what will be committed)
>  (use "git checkout -- <file>..." to discard changes in working directory)
> 
>        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_saturationPressure.txt
> 
> user@mac:/tmp/IDEAS>


```

## Duy Nguyen, 2018-02-06 13:19

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <CACsJy8A-KCzMCK34w_qNOQH2urwoQ-NmFZ+iR6Hyc3TQjGz1fg@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8A-KCzMCK34w_qNOQH2urwoQ-NmFZ%2BiR6Hyc3TQjGz1fg%40mail.gmail.com
In-Reply-To: <CD3563ED-5E0D-4238-A664-4F2335598FE2@kuleuven.be>

```
On Tue, Feb 6, 2018 at 8:09 PM, Filip Jorissen
<filip.jorissen@kuleuven.be> wrote:
> Hi all,
>
> Thank you for your quick responses. I was able to resolve the problem based on your feedback!
>
> Based on this experience, I would like to suggest that git is somehow able to avoid these problems by doing a case check itself rather than relying on the host OS for this?

Git itself can't resolve the problem. Case checking is just a side
problem. You have two paths, only one of which can be checked out by
your OS. How can Git know which one to checkout?

Git could pick one at random and hide the other (using sparse
checkout, behind the scene). But that can still surprise the user "how
come I see this content (of file "AAA") while the other user see
another content (of file "aaa")?"

I don't see a good solution for this. I think the best we could do is
warn earlier at clone time "trouble ahead! Your repository and your OS
don't like each other!" so that users won't get puzzled at "git
status" later. Would that help?

> Kind regards!
>
> Filip
-- 
Duy

```

## Ævar Arnfjörð Bjarmason, 2018-02-06 13:24

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <87lgg6l08m.fsf@evledraar.gmail.com>
URL: https://gitlist.dev/e/87lgg6l08m.fsf%40evledraar.gmail.com
In-Reply-To: <CD3563ED-5E0D-4238-A664-4F2335598FE2@kuleuven.be>

```

On Tue, Feb 06 2018, Filip Jorissen jotted:

> Hi all,
>
> Thank you for your quick responses. I was able to resolve the problem based on your feedback!
>
> Based on this experience, I would like to suggest that git is somehow able to avoid these problems by doing a case check itself rather than relying on the host OS for this?

I think it would make a lot of sense for git to ship with some standard
library of hooks for people to enable that covered common cases like
that.

But it's important to realize that:

 1) That's all this would be, this check would just be something you can
    do via a pre-receive hook now (or in this case, that big hosting
    providers like Github could offer as a pre-receive hook).

 2) Case collisions are just a subset of these issues, if you look at my
    CACBZZX4qH-w3YevoaW8RXAoFrjpfGerLWpBhetrO2tV-FGr3cQ@mail.gmail.com
    here on-list you'll see an issue relating to unicode normalizing
    that triggers a similar problem.

 3) Such hooks slow down pushes, especially on big repos, you can
    optimize things a bit (e.g. only look in the same directories), but
    pathologically you end up needing to compare the cross-product of
    changed files v.s. all existing files for each changed file.

 4) It's not something hosting providers like Github, Gitlab etc. can
    just enable, because some people want it like this. There's a lot of
    repos that have e.g. case collisions or other problems that only
    manifest on some OS-specific limitation (e.g. paths that are too
    long for VMS), and none of the users care because they don't use the
    repo on those systems.

    So it's not something that can be enabled by default, even for the
    most common case of case collisions.

Right now you're probably best off setting up a CI check on Github that
checks whether someone commits a colliding file, and poking Github about
maybe providing some opt-in feature to check for this.

I think the most performant way of checking this is:

    git --icase-pathspecs ls-files -- <changed files>

Which should never emit more lines than you give to it, you'd run that
either for the tip of the push, or if you want to be more thorough for
each pushed commit.

If someone can think of a better way to check for this I'd love to hear
about it, I'll probably add a check like this to some of our internal
repos soon. We semi-regularly have Mac users up in arms because someone
pushed a case-colliding file on Linux.

>> Op 28 jan. 2018, om 08:57 heeft Torsten Bögershausen <tboegi@web.de> het volgende geschreven:
>>
>> On Sat, Jan 27, 2018 at 08:59:50PM +0100, Ævar Arnfjörð Bjarmason wrote:
>>>
>>> On Sat, Jan 27 2018, Filip Jorissen jotted:
>>>
>>>> I think our git repository is bugged. The reason why I say this is the
>>>> following. When cloning the repository, the newly cloned repository
>>>> immediately has file changes[...].
>>>
>>> If you run this:
>>>
>>>    git ls-files | tr '[:upper:]' '[:lower:]' | sort | uniq -D | grep '^'
>>>
>>> You'll see that the reason is that you have files that differ only in
>>> case.
>>>
>>> You are using a Mac, and Macs by default think that files that are
>>> different binary strings are the same file, since they don't consider
>>> case to be relevant. The file FOO, foo and FoO and fOo are all the same
>>> file as far as your Mac is concerned, but would be 4 different files on
>>> Linux.
>>>
>>>> How can I fix the repository?
>>>
>>> You could check it out on a OS that considers files that differ in case
>>> to be different files, e.g. on Linux, move them around, push it, and new
>>> clones should work on your Mac.
>>>
>>> Alternatively I hear that you can create a loopback case-sensitive FS
>>> image on Macs.
>>
>> You can even fix the repo locally.
>> There are 2 files with uppercase/lowercase collisions.
>> I show you how to fix one off these, the other one goes similar.
>> After that, do a commit and a push and pull request.
>>
>>
>>
>> Changes not staged for commit:
>>  (use "git add <file>..." to update what will be committed)
>>  (use "git checkout -- <file>..." to discard changes in working directory)
>>
>>        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
>>        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_saturationPressure.txt
>>
>> no changes added to commit (use "git add" and/or "git commit -a")
>> user@mac:/tmp/IDEAS> git ls-files -s | grep -i IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
>> 100644 f56cfcf14aa4b53dfc5ecfb488366f721c94c8e2 0       IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
>> 100644 e345e1372111d034b4c5a1c75eb791340b93f55e 0       IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
>> user@mac:/tmp/IDEAS> git mv IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
>> user@mac:/tmp/IDEAS> git checkout  IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
>> user@mac:/tmp/IDEAS> git checkout IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt
>> user@mac:/tmp/IDEAS> git status
>> On branch master
>> Your branch is up to date with 'origin/master'.
>>
>> Changes to be committed:
>>  (use "git reset HEAD <file>..." to unstage)
>>
>>        renamed:    IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump.txt -> IDEAS/Resources/ReferenceResults/Dymola/ideas_Fluid_HeatExchangers_GroundHeatExchangers_Borefield_Examples_MultipleBoreholesWithHeatPump2.txt
>>
>> Changes not staged for commit:
>>  (use "git add <file>..." to update what will be committed)
>>  (use "git checkout -- <file>..." to discard changes in working directory)
>>
>>        modified:   IDEAS/Resources/ReferenceResults/Dymola/IDEAS_Utilities_Psychrometrics_Functions_Examples_saturationPressure.txt
>>
>> user@mac:/tmp/IDEAS>

```

## Jeff King, 2018-02-06 14:14

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <20180206141423.GA28721@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20180206141423.GA28721%40sigill.intra.peff.net
In-Reply-To: <87lgg6l08m.fsf@evledraar.gmail.com>

```
On Tue, Feb 06, 2018 at 02:24:25PM +0100, Ævar Arnfjörð Bjarmason wrote:

>  3) Such hooks slow down pushes, especially on big repos, you can
>     optimize things a bit (e.g. only look in the same directories), but
>     pathologically you end up needing to compare the cross-product of
>     changed files v.s. all existing files for each changed file.

I think you could just complain about any tree that contains entries
that have duplicate entries after normalization. I.e.:

  git rev-list --objects $new --not $old |
  awk '{print $1}' |
  git cat-file --batch-check='%(objecttype) %(objectname)' |
  awk '/^tree/ {print $2}'|
  while read tree; do
	dups=$(git ls-tree $tree | cut -f 2- | tr A-Z a-z | sort | uniq -d)
	test -z "$dups" || echo "$tree has duplicates: $dups"
  done

That gives reasonable algorithmic complexity, but of course the shell
implementation is horrific. One could imagine that this could be
implemented as part of fsck_tree(), though, which is already reading
through all the entries (unfortunately it requires auxiliary storage
linear with the size of a given tree object, but that's not too bad).

But it would probably need:

  1. To be enabled as an optional fsck warning, possibly even defaulting
     to "ignore".

  2. That "tr" could be any arbitrary transformation. Case-folding is
     the obvious one, but in theory you could match the normalization
     behavior of certain popular filesystems.

I'm not entirely convinced it's worth all of this effort, but I think it
would be _possible_ at least.

-Peff

```

## Filip Jorissen, 2018-02-06 14:30

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <5C27A062-A03B-4A4B-978E-40CFD78FC1AB@kuleuven.be>
URL: https://gitlist.dev/e/5C27A062-A03B-4A4B-978E-40CFD78FC1AB%40kuleuven.be
In-Reply-To: <20180206141423.GA28721@sigill.intra.peff.net>

```
I’m not git expert but, from a user point of view, the following would make sense. When adding a file, git could check whether a different file is already in the repository with the same name (case-insensitive check). Then simply report that this may be a mistake and request to use ‘git add -f’ to force the ‘add’. Perhaps this coincides with what was suggested in earlier replies. From my point of view the check should be enabled by default, but it could be optional too. 

Filip



> Op 6 feb. 2018, om 15:14 heeft Jeff King <peff@peff.net> het volgende geschreven:
> 
> On Tue, Feb 06, 2018 at 02:24:25PM +0100, Ævar Arnfjörð Bjarmason wrote:
> 
>> 3) Such hooks slow down pushes, especially on big repos, you can
>>    optimize things a bit (e.g. only look in the same directories), but
>>    pathologically you end up needing to compare the cross-product of
>>    changed files v.s. all existing files for each changed file.
> 
> I think you could just complain about any tree that contains entries
> that have duplicate entries after normalization. I.e.:
> 
>  git rev-list --objects $new --not $old |
>  awk '{print $1}' |
>  git cat-file --batch-check='%(objecttype) %(objectname)' |
>  awk '/^tree/ {print $2}'|
>  while read tree; do
> 	dups=$(git ls-tree $tree | cut -f 2- | tr A-Z a-z | sort | uniq -d)
> 	test -z "$dups" || echo "$tree has duplicates: $dups"
>  done
> 
> That gives reasonable algorithmic complexity, but of course the shell
> implementation is horrific. One could imagine that this could be
> implemented as part of fsck_tree(), though, which is already reading
> through all the entries (unfortunately it requires auxiliary storage
> linear with the size of a given tree object, but that's not too bad).
> 
> But it would probably need:
> 
>  1. To be enabled as an optional fsck warning, possibly even defaulting
>     to "ignore".
> 
>  2. That "tr" could be any arbitrary transformation. Case-folding is
>     the obvious one, but in theory you could match the normalization
>     behavior of certain popular filesystems.
> 
> I'm not entirely convinced it's worth all of this effort, but I think it
> would be _possible_ at least.
> 
> -Peff


```

## Junio C Hamano, 2018-02-06 14:36

Subject: Re: Cloned repository has file changes -> bug?
Message-ID: <xmqqinba89tb.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqinba89tb.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <20180206141423.GA28721@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> I'm not entirely convinced it's worth all of this effort, but I think it
> would be _possible_ at least.

I thought that the original poster wants to have a knob that the
project can ask its participants to enable in their clones of the
repository that wars this situation when they "git add".  When a
projects considers that macOS users must dictate the world order
because its source must be checked out on case insensitive HFS+, it
may be sensible to force participants on other platforms whose
filesystem does not guarantee that two paths that "normalize" to the
same string will not enter in the project history to spend
application cycles to do so instead.

That admittedly is quite a macOS centric view, and it is not a very
pleasant one, as it means almost all individual _applications_ on
other platforms that conceivably could be used to work on a project
macOS folks would want to be treated as first-class citizens would
need to learn about the peculiar filesystem limitation of one
particular platform they otherwise may not necessarily care about.


```
