public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Adam Dinwoodie <adam@dinwoodie.org>
To: cygwin@cygwin.com
Subject: Re: Problem with git and file mode changes
Date: Fri, 04 Sep 2015 15:12:00 -0000	[thread overview]
Message-ID: <20150904151229.GB14466@dinwoodie.org> (raw)
In-Reply-To: <CAH8Pv0jXEEJ5P4jmojYne_SAt-DtK7twGLuujFCukoAhr1-f8g@mail.gmail.com>

On Fri, Sep 04, 2015 at 04:44:11PM +0200, Dani Moncayo wrote:
> After doing a 'git pull', I saw that git didn't make the merge,
> because apparently I had some local changes.  But I didn't make
> any local change.  For example, this file appears as modified:
> 
>   $ git status --short test/rmailmm.el
>    M test/rmailmm.el
> 
>   $ git diff test/rmailmm.el
>   diff --git a/test/rmailmm.el b/test/rmailmm.el
>   old mode 100644
>   new mode 100755
> 
> Mmm strange, I never changed the permissions of any file in my
> repo.  And moreover:
> 
>   $ ls -o test/rmailmm.el
>   -rwxrwxr--+ 1 Dani 3106 Sep 4 16:19 test/rmailmm.el
> 
> According to 'ls', the file mode is 774, but according to git is
> 755.  Which one is wrong?

Git internally only stores file permissions of 755 or 644*; anything
else is mapped down to one of those two, based (I believe) on whether
the user execute bit is set or not.

> Well, let's try to revert the misterious change:
> 
>   $ git checkout test/rmailmm.el
> 
>   $ git status --short test/rmailmm.el
>    M test/rmailmm.el
> 
>   $ git diff test/rmailmm.el
>   diff --git a/test/rmailmm.el b/test/rmailmm.el
>   old mode 100644
>   new mode 100755
> 
>   $ ls -o test/rmailmm.el
>   -rwxrwxr--+ 1 Dani 3106 Sep  4 16:28 test/rmailmm.el
> 
> Apparently nothing has changed after the 'git checkout'!!

It looks like the underlying file system is failing to record the file
permissions correctly**.  That could be a limitation of the file system
(FAT32 is much more limited than NTFS, for example, and I could believe
permissions go very wrong over network shares), of the options with
which the filesystem is mounted in Cygwin (take a look for "noacl" in
the Cygwin FAQs), or possibly just that you don't have permission to
change the file properties (although I'd expect an error in that
scenario).  Another option is that some non-Cygwin program is getting in
the way and interfering with the permissions.

The underlying problem here is that Cygwin is trying to write a file
without the executable bit set, but whenever it checks the filesystem,
it sees the executable bit is set, and so has to assume that's a change.
If you can't fix the filesystem, you can tell Git to ignore the
filesystem executable bit with

    git config --global --bool core.fileMode false

(Remove the `--global` to only change it for the current repository.)

If you do that, you'll need to use `git update-index` if you need to
change the executable bit as recorded in the Git repository; see `git
help update-index` under the `--chmod` option for details.

HTH

Adam

* There are some special values stored in the same way as permissions
to denote things like submodules or symlinks, but the above is correct
as far as simple files are concerned.

** Where by "correctly" I mean "in the POSIX-like style that Cygwin
understands and uses"; it probably is correct from a Windows
perspective.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2015-09-04 15:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 14:44 Dani Moncayo
2015-09-04 15:12 ` Adam Dinwoodie [this message]
2015-09-04 18:26   ` Ken Brown
2015-09-05 10:13 ` Dani Moncayo
2015-09-05 12:05   ` Andrey Repin
2015-09-05 15:03   ` Mailing list CCing etiquette [Was: Problem with git and file mode changes] Adam Dinwoodie

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=20150904151229.GB14466@dinwoodie.org \
    --to=adam@dinwoodie.org \
    --cc=cygwin@cygwin.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).