threads / discuss / 29170

[msysGit] Windows & executable bit for newly created files

Subject: [msysGit] Windows & executable bit for newly created files

## tl;dr

3 messages between Dec 15, 2011 and Dec 16, 2011.

replies: 2people: 2as markdown or json

Dirk Süsserott· Dec 15, 2011, 20:07 UTC · lore
Hi,

I sometimes write new (shell/perl) scripts under Windows whithin msysGit's bash. An "ls -l" shows them as executable:

$ ls -l
    -rwxr-xr-x  ...  11 Dec 15 20:33 test.sh

Ok, "ls" just *pretends* they have the bit set (I think it just peeks for the she-bang line).

Adding the file and looking at the patch gives:

$ git add test.sh $ git diff --cached

    diff --git a/test.sh b/test.sh
    new file mode 100644
    index 0000000..13f4793
    --- /dev/null
    +++ b/test.sh
    @@ -0,0 +1,2 @@
    +#!/bin/sh
    +

Is there a way to convince git that the new mode is 755 instead of 644, even with core.filemode set to false? So that the mode is correct when I checkout the file under Linux later on?

My impression is that when git once knows the file has 755, it remembers that. I'd like to avoid those commits (made under Linux) with "chmod +x for scripts newly created under Windows".

Sometimes I create a script under Windows, add and commit it, create a patch (git-format-patch), edit the patch (644 -> 755), reset the branch, and finally git-am the patch. It works but is not particularly convenient.

Is there sth. like
$ git add --filemode=755 <filepattern>   ?
Cheers,
    Dirk
Junio C Hamano· Dec 15, 2011, 20:56 UTC · re: Dirk Süsserott · lore

Re: [msysGit] Windows & executable bit for newly created files

Dirk Süsserott <newsletter@dirk.my1.cc> writes:
> Is there a way to convince git that the new mode is 755 instead of 644,
> even with core.filemode set to false? So that the mode is correct when I
> checkout the file under Linux later on?
"git update-index --chmod=+x"?
Dirk Süsserott· Dec 16, 2011, 18:27 UTC · re: Junio C Hamano · lore

Re: [msysGit] Windows & executable bit for newly created files

Am 15.12.2011 21:56 schrieb Junio C Hamano:
Show 8 quoted lines
> Dirk Süsserott <newsletter@dirk.my1.cc> writes:
> 
>> Is there a way to convince git that the new mode is 755 instead of 644,
>> even with core.filemode set to false? So that the mode is correct when I
>> checkout the file under Linux later on?
> 
> "git update-index --chmod=+x"?
> 
Oh, thanks. I wasn't aware of that option. Works exactly as I like.
Dirk

← back to recent threads