# Git an case-insensitive Mac OS X filesystem

10 messages from 2012-09-11 to 2012-09-11. Participants: Roger Pau Monné, Tomas Carnecky, Erik Faye-Lund, Matthieu Moy, Junio C Hamano.
Thread: https://gitlist.dev/t/31498

## Roger Pau Monné, 2012-09-11 09:21

Subject: Git an case-insensitive Mac OS X filesystem
Message-ID: <CAPLaKK71O3RzavOqY2uVC1tUsbs+W6WxJRWuLBDFUvTwojAN-g@mail.gmail.com>
URL: https://gitlist.dev/e/CAPLaKK71O3RzavOqY2uVC1tUsbs%2BW6WxJRWuLBDFUvTwojAN-g%40mail.gmail.com

```
Hello,

I'm using git for all my projects, and I usually work under Mac OS X
with the default filesystem (that's case-insensitive, but
case-preserving). I'm currently working on a project that has several
branches, and two of them are called origin/DHCPCD and origin/dhcpcd
respectively, that's unfortunate, but I cannot do anything about it.
This completely breaks the git repository, because
.git/refs/remotes/origin/DHCPD and .git/refs/remotes/origin/dhcpd are
actually the same file, so when I try to update my repository
performing a git pull I get the following error:

error: Ref refs/remotes/origin/dhcpcd is at
6b371783de2def2d6e3ec2680ba731f7086067ee but expected
79f701ce599a27043eed8343f76406014963278a

So I was wondering if anyone has stumbled upon this issue, and what's
the best approach to fix it.

Thanks, Roger.

```

## Roger Pau Monné, 2012-09-11 09:30

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <CAPLaKK4Xm8KzQ8HcM_TbbuDr1hcLjhjSOWSyJS3jFX0toFBjsA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPLaKK4Xm8KzQ8HcM_TbbuDr1hcLjhjSOWSyJS3jFX0toFBjsA%40mail.gmail.com
In-Reply-To: <1347355466-ner-6656@calvin>

```
On Tue, Sep 11, 2012 at 10:24 AM, Tomas Carnecky
<tomas.carnecky@gmail.com> wrote:
> On Tue, 11 Sep 2012 10:21:16 +0100, Roger Pau Monné <roger.pau@entel.upc.edu> wrote:
>> Hello,
>>
>> I'm using git for all my projects, and I usually work under Mac OS X
>> with the default filesystem (that's case-insensitive, but
>> case-preserving). I'm currently working on a project that has several
>> branches, and two of them are called origin/DHCPCD and origin/dhcpcd
>> respectively, that's unfortunate, but I cannot do anything about it.
>> This completely breaks the git repository, because
>> .git/refs/remotes/origin/DHCPD and .git/refs/remotes/origin/dhcpd are
>> actually the same file, so when I try to update my repository
>> performing a git pull I get the following error:
>>
>> error: Ref refs/remotes/origin/dhcpcd is at
>> 6b371783de2def2d6e3ec2680ba731f7086067ee but expected
>> 79f701ce599a27043eed8343f76406014963278a
>>
>> So I was wondering if anyone has stumbled upon this issue, and what's
>> the best approach to fix it.
>
> Make a disk image and format it with a case sensitive filesystem (use the Disk
> Utility to do that). Do your work there.

Yes, I could also create a partition, or format my entire disk to
case-sensitive (although I heard it might break some OS X
applications), I guess adding a workaround for this in git itself is
not appealing (like storing the branch file using a slightly different
name?)

```

## Tomas Carnecky, 2012-09-11 09:36

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <CAPabhsKrnFq3z6wTcZny+Jh1PF-7arx_r8WyNRHmgQUu=U4sig@mail.gmail.com>
URL: https://gitlist.dev/e/CAPabhsKrnFq3z6wTcZny%2BJh1PF-7arx_r8WyNRHmgQUu%3DU4sig%40mail.gmail.com
In-Reply-To: <CAPLaKK4Xm8KzQ8HcM_TbbuDr1hcLjhjSOWSyJS3jFX0toFBjsA@mail.gmail.com>

```
On Tue, Sep 11, 2012 at 9:30 AM, Roger Pau Monné
<roger.pau@entel.upc.edu> wrote:
> On Tue, Sep 11, 2012 at 10:24 AM, Tomas Carnecky
> <tomas.carnecky@gmail.com> wrote:
>> On Tue, 11 Sep 2012 10:21:16 +0100, Roger Pau Monné <roger.pau@entel.upc.edu> wrote:
>>> Hello,
>>>
>>> I'm using git for all my projects, and I usually work under Mac OS X
>>> with the default filesystem (that's case-insensitive, but
>>> case-preserving). I'm currently working on a project that has several
>>> branches, and two of them are called origin/DHCPCD and origin/dhcpcd
>>> respectively, that's unfortunate, but I cannot do anything about it.
>>> This completely breaks the git repository, because
>>> .git/refs/remotes/origin/DHCPD and .git/refs/remotes/origin/dhcpd are
>>> actually the same file, so when I try to update my repository
>>> performing a git pull I get the following error:
>>>
>>> error: Ref refs/remotes/origin/dhcpcd is at
>>> 6b371783de2def2d6e3ec2680ba731f7086067ee but expected
>>> 79f701ce599a27043eed8343f76406014963278a
>>>
>>> So I was wondering if anyone has stumbled upon this issue, and what's
>>> the best approach to fix it.
>>
>> Make a disk image and format it with a case sensitive filesystem (use the Disk
>> Utility to do that). Do your work there.
>
> Yes, I could also create a partition, or format my entire disk to
> case-sensitive (although I heard it might break some OS X
> applications), I guess adding a workaround for this in git itself is
> not appealing (like storing the branch file using a slightly different
> name?)

No, I'm not talking about a partition. I'm talking about a Mac OS X
disk image (eg. http://en.wikipedia.org/wiki/.dmg).

```

## Roger Pau Monné, 2012-09-11 09:44

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <CAPLaKK6R=BNjgY8wc8nZzyPy53ppeO4bKN=Cum_+b6Kwb5F=SA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPLaKK6R%3DBNjgY8wc8nZzyPy53ppeO4bKN%3DCum_%2Bb6Kwb5F%3DSA%40mail.gmail.com
In-Reply-To: <CAPabhsKrnFq3z6wTcZny+Jh1PF-7arx_r8WyNRHmgQUu=U4sig@mail.gmail.com>

```
On Tue, Sep 11, 2012 at 10:36 AM, Tomas Carnecky
<tomas.carnecky@gmail.com> wrote:
> On Tue, Sep 11, 2012 at 9:30 AM, Roger Pau Monné
> <roger.pau@entel.upc.edu> wrote:
>> On Tue, Sep 11, 2012 at 10:24 AM, Tomas Carnecky
>> <tomas.carnecky@gmail.com> wrote:
>>> On Tue, 11 Sep 2012 10:21:16 +0100, Roger Pau Monné <roger.pau@entel.upc.edu> wrote:
>>>> Hello,
>>>>
>>>> I'm using git for all my projects, and I usually work under Mac OS X
>>>> with the default filesystem (that's case-insensitive, but
>>>> case-preserving). I'm currently working on a project that has several
>>>> branches, and two of them are called origin/DHCPCD and origin/dhcpcd
>>>> respectively, that's unfortunate, but I cannot do anything about it.
>>>> This completely breaks the git repository, because
>>>> .git/refs/remotes/origin/DHCPD and .git/refs/remotes/origin/dhcpd are
>>>> actually the same file, so when I try to update my repository
>>>> performing a git pull I get the following error:
>>>>
>>>> error: Ref refs/remotes/origin/dhcpcd is at
>>>> 6b371783de2def2d6e3ec2680ba731f7086067ee but expected
>>>> 79f701ce599a27043eed8343f76406014963278a
>>>>
>>>> So I was wondering if anyone has stumbled upon this issue, and what's
>>>> the best approach to fix it.
>>>
>>> Make a disk image and format it with a case sensitive filesystem (use the Disk
>>> Utility to do that). Do your work there.
>>
>> Yes, I could also create a partition, or format my entire disk to
>> case-sensitive (although I heard it might break some OS X
>> applications), I guess adding a workaround for this in git itself is
>> not appealing (like storing the branch file using a slightly different
>> name?)
>
> No, I'm not talking about a partition. I'm talking about a Mac OS X
> disk image (eg. http://en.wikipedia.org/wiki/.dmg).

I understood this, it's just that I would prefer to avoid doing this
kind if things, I would prefer to be able to work natively on my
filesystem, but it seems like there's no other option.

Thanks, Roger.

```

## Erik Faye-Lund, 2012-09-11 10:06

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <CABPQNSYv1hd8RFHfcQ1XTB94nu6xo+tjj4CvWur29152z2dk6A@mail.gmail.com>
URL: https://gitlist.dev/e/CABPQNSYv1hd8RFHfcQ1XTB94nu6xo%2Btjj4CvWur29152z2dk6A%40mail.gmail.com
In-Reply-To: <CAPLaKK71O3RzavOqY2uVC1tUsbs+W6WxJRWuLBDFUvTwojAN-g@mail.gmail.com>

```
On Tue, Sep 11, 2012 at 11:21 AM, Roger Pau Monné
<roger.pau@entel.upc.edu> wrote:
> Hello,
>
> I'm using git for all my projects, and I usually work under Mac OS X
> with the default filesystem (that's case-insensitive, but
> case-preserving). I'm currently working on a project that has several
> branches, and two of them are called origin/DHCPCD and origin/dhcpcd
> respectively, that's unfortunate, but I cannot do anything about it.
> This completely breaks the git repository, because
> .git/refs/remotes/origin/DHCPD and .git/refs/remotes/origin/dhcpd are
> actually the same file, so when I try to update my repository
> performing a git pull I get the following error:
>
> error: Ref refs/remotes/origin/dhcpcd is at
> 6b371783de2def2d6e3ec2680ba731f7086067ee but expected
> 79f701ce599a27043eed8343f76406014963278a
>
> So I was wondering if anyone has stumbled upon this issue, and what's
> the best approach to fix it.
>

I have stumbled upon a similar issue on Windows (which also has a
case-preserving filesystem), and I seem to remember the solution being
something to do with packed refs.

Perhaps we could change Git to detect name-collisions and
automatically pack the refs in such cases?

```

## Matthieu Moy, 2012-09-11 10:28

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <vpq392og8fg.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpq392og8fg.fsf%40bauges.imag.fr
In-Reply-To: <CABPQNSYv1hd8RFHfcQ1XTB94nu6xo+tjj4CvWur29152z2dk6A@mail.gmail.com>

```
Erik Faye-Lund <kusmabite@gmail.com> writes:

> I have stumbled upon a similar issue on Windows (which also has a
> case-preserving filesystem), and I seem to remember the solution being
> something to do with packed refs.

Packed-refs use a format like this:

$ tail -3 .git/packed-refs
e94214ce4b8acefce06d4ea37b76ac0de11ecb2d refs/tags/v1.7.9.5
bf68fe0313c833fa62755176f6e24988ef7cf80f refs/tags/v1.7.9.6
3996bb24c84013ec9ce9fa0980ce61f9ef97be4d refs/tags/v1.7.9.7

so the ref name is stored within the file, not as the file name. So,
yes, packing refs (done by "git pack-refs", called by "git gc" among
other things) should solve case-insensitive issues.

However, creating or updating refs after a pack will still create
unpacked refs, so this solves the issue only if one of the colliding
branches is not updated anymore.

> Perhaps we could change Git to detect name-collisions and
> automatically pack the refs in such cases?

That's a bit harder than it seems, as the idea is to avoid re-writting
the packed-refs file for each ref update. Repacking after each colliding
ref update could be costly in terms of performance.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Erik Faye-Lund, 2012-09-11 11:18

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <CABPQNSZznFvjCLR7A7sACf9NcESek7DmOeJcSSHFY1cGHwD2Jg@mail.gmail.com>
URL: https://gitlist.dev/e/CABPQNSZznFvjCLR7A7sACf9NcESek7DmOeJcSSHFY1cGHwD2Jg%40mail.gmail.com
In-Reply-To: <vpq392og8fg.fsf@bauges.imag.fr>

```
On Tue, Sep 11, 2012 at 12:28 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Erik Faye-Lund <kusmabite@gmail.com> writes:
>
>> I have stumbled upon a similar issue on Windows (which also has a
>> case-preserving filesystem), and I seem to remember the solution being
>> something to do with packed refs.
>
> Packed-refs use a format like this:
>
> $ tail -3 .git/packed-refs
> e94214ce4b8acefce06d4ea37b76ac0de11ecb2d refs/tags/v1.7.9.5
> bf68fe0313c833fa62755176f6e24988ef7cf80f refs/tags/v1.7.9.6
> 3996bb24c84013ec9ce9fa0980ce61f9ef97be4d refs/tags/v1.7.9.7
>
> so the ref name is stored within the file, not as the file name. So,
> yes, packing refs (done by "git pack-refs", called by "git gc" among
> other things) should solve case-insensitive issues.
>
> However, creating or updating refs after a pack will still create
> unpacked refs, so this solves the issue only if one of the colliding
> branches is not updated anymore.
>

Of course. In my case, the colliding refs weren't fetched from the
same source IIRC.

>> Perhaps we could change Git to detect name-collisions and
>> automatically pack the refs in such cases?
>
> That's a bit harder than it seems, as the idea is to avoid re-writting
> the packed-refs file for each ref update. Repacking after each colliding
> ref update could be costly in terms of performance.

Yes, but being costly in terms of performance is IMO a lot better than
corrupting refs, which is what we currently do.

And it should really only be costly in the case where there's actually
such a cost, on a file system where such a collision can happen.

```

## Matthieu Moy, 2012-09-11 11:25

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <vpqsjaodco8.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqsjaodco8.fsf%40bauges.imag.fr
In-Reply-To: <CABPQNSZznFvjCLR7A7sACf9NcESek7DmOeJcSSHFY1cGHwD2Jg@mail.gmail.com>

```
Erik Faye-Lund <kusmabite@gmail.com> writes:

> Yes, but being costly in terms of performance is IMO a lot better than
> corrupting refs, which is what we currently do.

I'm not saying nothing should be done, but I'm not sure packed-refs are
the right solution in the long term. We already have the foo Vs foo/bar
issue (discussed in the "keeping reflog for deleted refs" discussion). I
think the right way would be to re-think the way we map ref name to the
filesystem, with proper escaping of capitals, slashes, ...

But that's a rather big change to do (and I'm unlikely to be the one
volunteering for it :-( )

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2012-09-11 15:40

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <7vhar4k1o5.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vhar4k1o5.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAPLaKK71O3RzavOqY2uVC1tUsbs+W6WxJRWuLBDFUvTwojAN-g@mail.gmail.com>

```
Roger Pau Monné <roger.pau@entel.upc.edu> writes:

> Hello,
>
> I'm using git for all my projects, and I usually work under Mac OS X
> with the default filesystem (that's case-insensitive, but
> case-preserving). I'm currently working on a project that has several
> branches, and two of them are called origin/DHCPCD and origin/dhcpcd
> respectively, that's unfortunate, but I cannot do anything about it.
> This completely breaks the git repository, because
> .git/refs/remotes/origin/DHCPD and .git/refs/remotes/origin/dhcpd are
> actually the same file, so when I try to update my repository
> performing a git pull I get the following error:
>
> error: Ref refs/remotes/origin/dhcpcd is at
> 6b371783de2def2d6e3ec2680ba731f7086067ee but expected
> 79f701ce599a27043eed8343f76406014963278a
>
> So I was wondering if anyone has stumbled upon this issue, and what's
> the best approach to fix it.

If "several" is manageably small, you can configure your refspecs to
rename them, e.g.

	[remote "origin"]
		url = ...
                fetch = +refs/heads/master:refs/remotes/origin/master
                fetch = +refs/heads/dhcpcd:refs/remotes/origin/dhcpcd
                fetch = +refs/heads/DHCPCD:refs/remotes/origin/dhcpcd-u

which tells

	$ git fetch origin

to use your remote tracking branch origin/dhcpcd-u to copy from
their DHCPCD.  Then you can work on it the usual way.

	$ git checkout -b dhcpcd-u origin/dhcpcd-u
        $ work work work

For pushing, you can rename it back in a similar way.

        $ git push origin dhcpcd-u:DHCPCD

which is a short-hand for

        $ git push origin refs/heads/dhcpcd-u:refs/heads/DHCPCD

```

## Junio C Hamano, 2012-09-11 15:44

Subject: Re: Git an case-insensitive Mac OS X filesystem
Message-ID: <7va9wwk1iq.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7va9wwk1iq.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAPLaKK6R=BNjgY8wc8nZzyPy53ppeO4bKN=Cum_+b6Kwb5F=SA@mail.gmail.com>

```
Roger Pau Monné <roger.pau@entel.upc.edu> writes:

> I understood this, it's just that I would prefer to avoid doing this
> kind if things, I would prefer to be able to work natively on my
> filesystem, but it seems like there's no other option.

If you are unwilling to keep both lowercase and uppercase separately
on your end, and if the other side (the project you are interacting
with) wants you to have both, then I do not think there is any way
to resolve such conflict between you and your project.

```
