{"thread":{"id":"53352","subject":"git fast-export not preserving executable permissions?","startedAt":"2020-04-29T13:36:47Z","lastAt":"2020-05-04T21:24:48Z","messageCount":6,"participants":["Doug Glidden","Taylor Blau","Torsten Bögershausen","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"396555","messageId":"CAHTRwmjXXYAU_LTBF_9sX1CXFnGyHsu5_KHuCp1rB76-4zn=Gg@mail.gmail.com","threadId":"53352","inReplyTo":null,"subject":"git fast-export not preserving executable permissions?","fromName":"Doug Glidden","fromEmail":"41mortimer@gmail.com","sentAt":"2020-04-29T13:36:31Z","receivedAt":"2020-04-29T13:36:47Z","isPatch":false,"sender":{"key":"41mortimer@gmail.com","avatar":null},"body":"Hello Git world!\n\nI have run into an issue that I cannot seem to resolve with git\nfast-export. When running a fast-export on a repo that contains\nscripts with executable permissions (e.g. a gradlew script), the\nresulting export does not properly reflect the executable permissions\non the script files.\n\nTo illustrate this issue, I created a small sample repo, with one\nexecutable file and one non-executable file. From the output below,\nyou can see that the mode in the output from fast-export is the same\nfor both files; according to the documentation for fast-import, the\nmode for the executable file should be 100755 instead of 100644.\n\n    $ ls -gG\n    total 2\n    -rwxr-xr-x 1 106 Apr 29 09:13 executable_script.sh*\n    -rw-r--r-- 1  63 Apr 29 09:12 non_executable_file.txt\n\n    $ git fast-export --all\n    blob\n    mark :1\n    data 106\n    #!/bin/bash\n\n    # This is a shell script that should be executable.\n    echo 'The script executed successfully!'\n\n    blob\n    mark :2\n    data 63\n    This file is a simple text file that should not be executable.\n\n    reset refs/heads/dev\n    commit refs/heads/dev\n    mark :3\n    author Doug <41mortimer@gmail.com> 1588167102 -0400\n    committer Doug <41mortimer@gmail.com> 1588167102 -0400\n    data 25\n    Adding some sample files\n    M 100644 :1 executable_script.sh\n    M 100644 :2 non_executable_file.txt\n\nPlease let me know if there is any further information I can provide\nabout this issue.\n\nThank you,\nDoug\n"},{"id":"396586","messageId":"20200429184909.GE83442@syl.local","threadId":"53352","inReplyTo":"CAHTRwmjXXYAU_LTBF_9sX1CXFnGyHsu5_KHuCp1rB76-4zn=Gg@mail.gmail.com","subject":"Re: git fast-export not preserving executable permissions?","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-04-29T18:49:09Z","receivedAt":"2020-04-29T18:49:15Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi Doug,\n\nOn Wed, Apr 29, 2020 at 09:36:31AM -0400, Doug Glidden wrote:\n> Hello Git world!\n>\n> I have run into an issue that I cannot seem to resolve with git\n> fast-export. When running a fast-export on a repo that contains\n> scripts with executable permissions (e.g. a gradlew script), the\n> resulting export does not properly reflect the executable permissions\n> on the script files.\n\nInteresting. fast-import and fast-export both understand executable\nmodes (although Git only understands the modes 644 and 755 for blobs),\nso this should be working.\n\nI can not reproduce the issue as-is. Round-tripping a fast-import and\nfast-export preserves executable bits for me:\n\n  #!/bin/bash\n\n  set -e\n\n  rm -rf repo client\n\n  git init -q repo\n  git init -q client\n\n  (\n    cd repo\n    printf \"x\" >x\n    printf \"y\" >y\n    chmod +x x\n    git add x y\n    git commit -q -m \"initial commit\"\n  )\n\n  git -C repo fast-export HEAD | git -C client fast-import\n\n  diff -u <(git -C repo ls-tree HEAD) <(git -C client ls-tree HEAD)\n\n> To illustrate this issue, I created a small sample repo, with one\n> executable file and one non-executable file. From the output below,\n> you can see that the mode in the output from fast-export is the same\n> for both files; according to the documentation for fast-import, the\n> mode for the executable file should be 100755 instead of 100644.\n>\n>     $ ls -gG\n>     total 2\n>     -rwxr-xr-x 1 106 Apr 29 09:13 executable_script.sh*\n>     -rw-r--r-- 1  63 Apr 29 09:12 non_executable_file.txt\n>\n>     $ git fast-export --all\n>     blob\n>     mark :1\n>     data 106\n>     #!/bin/bash\n>\n>     # This is a shell script that should be executable.\n>     echo 'The script executed successfully!'\n>\n>     blob\n>     mark :2\n>     data 63\n>     This file is a simple text file that should not be executable.\n>\n>     reset refs/heads/dev\n>     commit refs/heads/dev\n>     mark :3\n>     author Doug <41mortimer@gmail.com> 1588167102 -0400\n>     committer Doug <41mortimer@gmail.com> 1588167102 -0400\n>     data 25\n>     Adding some sample files\n>     M 100644 :1 executable_script.sh\n>     M 100644 :2 non_executable_file.txt\n>\n> Please let me know if there is any further information I can provide\n> about this issue.\n\nDoes Git think that the file is executable? Please run 'git ls-tree\nHEAD' to find out.\n\n> Thank you,\n> Doug\n\nThanks,\nTaylor\n"},{"id":"396650","messageId":"20200430034230.smqu3ai5nx3ewbdq@tb-raspi4","threadId":"53352","inReplyTo":"CAHTRwmjXXYAU_LTBF_9sX1CXFnGyHsu5_KHuCp1rB76-4zn=Gg@mail.gmail.com","subject":"Re: git fast-export not preserving executable permissions?","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2020-04-30T03:42:31Z","receivedAt":"2020-04-30T03:42:35Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Apr 29, 2020 at 09:36:31AM -0400, Doug Glidden wrote:\n> Hello Git world!\n>\n> I have run into an issue that I cannot seem to resolve with git\n> fast-export. When running a fast-export on a repo that contains\n> scripts with executable permissions (e.g. a gradlew script), the\n> resulting export does not properly reflect the executable permissions\n> on the script files.\n>\n> To illustrate this issue, I created a small sample repo, with one\n> executable file and one non-executable file. From the output below,\n> you can see that the mode in the output from fast-export is the same\n> for both files; according to the documentation for fast-import, the\n> mode for the executable file should be 100755 instead of 100644.\n>\n>     $ ls -gG\n>     total 2\n>     -rwxr-xr-x 1 106 Apr 29 09:13 executable_script.sh*\n>     -rw-r--r-- 1  63 Apr 29 09:12 non_executable_file.txt\n\nWhat does\ngit ls-files -s\ngive you here ?\nWe need to know, how Git tracks the files, is it\n100644 or 100755 ?\n\nThe following works for me:\n\nuser@pc:/tmp/fff> git init\nInitialized empty Git repository in /private/tmp/fff/.git/\nuser@pc:/tmp/fff> echo file1 >file1\nuser@pc:/tmp/fff> git config core.filemode false\nuser@pc:/tmp/fff> echo file2 >file2\nuser@pc:/tmp/fff> git add file1 file2\nuser@pc:/tmp/fff> git ls-files -s\n100644 e2129701f1a4d54dc44f03c93bca0a2aec7c5449 0       file1\n100644 6c493ff740f9380390d5c9ddef4af18697ac9375 0       file2\nuser@pc:/tmp/fff> git update-index --chmod=+x file2\nuser@pc:/tmp/fff> git ls-files -s\n100644 e2129701f1a4d54dc44f03c93bca0a2aec7c5449 0       file1\n100755 6c493ff740f9380390d5c9ddef4af18697ac9375 0       file2\nuser@pc:/tmp/fff> git commit -m \"Add file1 file2\"\n[master (root-commit) f75926e] Add file1 file2\n 2 files changed, 2 insertions(+)\n  create mode 100644 file1\n  create mode 100755 file2\n\nuser@pc:/tmp/fff> git fast-export --all\nblob\nmark :1\ndata 6\nfile1\n\nblob\nmark :2\ndata 6\nfile2\n\nreset refs/heads/master\ncommit refs/heads/master\nmark :3\nauthor Torsten Bögershausen <tboegi@web.de> 1588217922 +0200\ncommitter Torsten Bögershausen <tboegi@web.de> 1588217922 +0200\ndata 16\nAdd file1 file2\nM 100644 :1 file1\nM 100755 :2 file2\n\n"},{"id":"396744","messageId":"CAHTRwmhhQCs4i04atAK66REiFJP_9e910MoYMt9iyu2v6S2jVw@mail.gmail.com","threadId":"53352","inReplyTo":"20200429184909.GE83442@syl.local","subject":"Re: git fast-export not preserving executable permissions?","fromName":"Doug Glidden","fromEmail":"41mortimer@gmail.com","sentAt":"2020-05-01T13:35:28Z","receivedAt":"2020-05-01T13:54:00Z","isPatch":false,"sender":{"key":"41mortimer@gmail.com","avatar":null},"body":"Taylor,\n\nThanks for your response! It looks like git does not actually\nrecognize the file as executable:\n\n    $ git ls-tree HEAD\n    100644 blob 7d2f57b2381766924e1e4ffcc62615c637bbd784    executable_script.sh\n    100644 blob d1d7cf309e091f54f268503b31653d8eba42fe88\nnon_executable_file.txt\n\nNow you have me wondering if the real problem here is that I'm working\nin git-bash on a Windows machine, which means the file permissions\naren't completely native. I'm going to run a similar experiment in a\nnative Linux environment and see if I get the same results. I'll let\nyou know what I find.\n\nThanks,\nDoug\n\n\n\nOn Wed, Apr 29, 2020 at 2:49 PM Taylor Blau <me@ttaylorr.com> wrote:\n>\n> Hi Doug,\n>\n> On Wed, Apr 29, 2020 at 09:36:31AM -0400, Doug Glidden wrote:\n> > Hello Git world!\n> >\n> > I have run into an issue that I cannot seem to resolve with git\n> > fast-export. When running a fast-export on a repo that contains\n> > scripts with executable permissions (e.g. a gradlew script), the\n> > resulting export does not properly reflect the executable permissions\n> > on the script files.\n>\n> Interesting. fast-import and fast-export both understand executable\n> modes (although Git only understands the modes 644 and 755 for blobs),\n> so this should be working.\n>\n> I can not reproduce the issue as-is. Round-tripping a fast-import and\n> fast-export preserves executable bits for me:\n>\n>   #!/bin/bash\n>\n>   set -e\n>\n>   rm -rf repo client\n>\n>   git init -q repo\n>   git init -q client\n>\n>   (\n>     cd repo\n>     printf \"x\" >x\n>     printf \"y\" >y\n>     chmod +x x\n>     git add x y\n>     git commit -q -m \"initial commit\"\n>   )\n>\n>   git -C repo fast-export HEAD | git -C client fast-import\n>\n>   diff -u <(git -C repo ls-tree HEAD) <(git -C client ls-tree HEAD)\n>\n> > To illustrate this issue, I created a small sample repo, with one\n> > executable file and one non-executable file. From the output below,\n> > you can see that the mode in the output from fast-export is the same\n> > for both files; according to the documentation for fast-import, the\n> > mode for the executable file should be 100755 instead of 100644.\n> >\n> >     $ ls -gG\n> >     total 2\n> >     -rwxr-xr-x 1 106 Apr 29 09:13 executable_script.sh*\n> >     -rw-r--r-- 1  63 Apr 29 09:12 non_executable_file.txt\n> >\n> >     $ git fast-export --all\n> >     blob\n> >     mark :1\n> >     data 106\n> >     #!/bin/bash\n> >\n> >     # This is a shell script that should be executable.\n> >     echo 'The script executed successfully!'\n> >\n> >     blob\n> >     mark :2\n> >     data 63\n> >     This file is a simple text file that should not be executable.\n> >\n> >     reset refs/heads/dev\n> >     commit refs/heads/dev\n> >     mark :3\n> >     author Doug <41mortimer@gmail.com> 1588167102 -0400\n> >     committer Doug <41mortimer@gmail.com> 1588167102 -0400\n> >     data 25\n> >     Adding some sample files\n> >     M 100644 :1 executable_script.sh\n> >     M 100644 :2 non_executable_file.txt\n> >\n> > Please let me know if there is any further information I can provide\n> > about this issue.\n>\n> Does Git think that the file is executable? Please run 'git ls-tree\n> HEAD' to find out.\n>\n> > Thank you,\n> > Doug\n>\n> Thanks,\n> Taylor\n"},{"id":"396797","messageId":"20200501223240.GG41612@syl.local","threadId":"53352","inReplyTo":"CAHTRwmhhQCs4i04atAK66REiFJP_9e910MoYMt9iyu2v6S2jVw@mail.gmail.com","subject":"Re: git fast-export not preserving executable permissions?","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-05-01T22:32:40Z","receivedAt":"2020-05-01T22:32:45Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Fri, May 01, 2020 at 09:35:28AM -0400, Doug Glidden wrote:\n> Taylor,\n\n(My full response is below, but please in general do not top-quote mail\nhere.)\n\n>\n> Thanks for your response! It looks like git does not actually\n> recognize the file as executable:\n>\n>     $ git ls-tree HEAD\n>     100644 blob 7d2f57b2381766924e1e4ffcc62615c637bbd784    executable_script.sh\n>     100644 blob d1d7cf309e091f54f268503b31653d8eba42fe88\n> non_executable_file.txt\n>\n> Now you have me wondering if the real problem here is that I'm working\n> in git-bash on a Windows machine, which means the file permissions\n> aren't completely native.\n\nI was wondering if that was the case ;-). If you are using NTFS or\nFAT32, neither of these filesystems support execute permission bits. (I\nam certainly not an expert here, but I know that Dscho (cc'd) would be\nable to answer authoritatively here.)\n\nThat said, *Git* understands executable permissions, even if your\nfilesystem doesn't. You can tell Git to mark a file as executable by\nthe following:\n\n  $ git update-index --chmod=+x /path/to/file\n\nand then committing the result. Round-tripping this through 'git\nfast-{im,ex}port' should preserve the permissions from Git's\nperspective, and ditto for checking out the contents of a repository on\na filesystem that does support the executable permission bit.\n\n> I'm going to run a similar experiment in a native Linux environment\n> and see if I get the same results. I'll let you know what I find.\n\nSounds good. I'll be very surprised if it doesn't work as you expect.\n\n> Thanks,\n> Doug\n>\n>\n>\n> On Wed, Apr 29, 2020 at 2:49 PM Taylor Blau <me@ttaylorr.com> wrote:\n> >\n> > Hi Doug,\n> >\n> > On Wed, Apr 29, 2020 at 09:36:31AM -0400, Doug Glidden wrote:\n> > > Hello Git world!\n> > >\n> > > I have run into an issue that I cannot seem to resolve with git\n> > > fast-export. When running a fast-export on a repo that contains\n> > > scripts with executable permissions (e.g. a gradlew script), the\n> > > resulting export does not properly reflect the executable permissions\n> > > on the script files.\n> >\n> > Interesting. fast-import and fast-export both understand executable\n> > modes (although Git only understands the modes 644 and 755 for blobs),\n> > so this should be working.\n> >\n> > I can not reproduce the issue as-is. Round-tripping a fast-import and\n> > fast-export preserves executable bits for me:\n> >\n> >   #!/bin/bash\n> >\n> >   set -e\n> >\n> >   rm -rf repo client\n> >\n> >   git init -q repo\n> >   git init -q client\n> >\n> >   (\n> >     cd repo\n> >     printf \"x\" >x\n> >     printf \"y\" >y\n> >     chmod +x x\n> >     git add x y\n> >     git commit -q -m \"initial commit\"\n> >   )\n> >\n> >   git -C repo fast-export HEAD | git -C client fast-import\n> >\n> >   diff -u <(git -C repo ls-tree HEAD) <(git -C client ls-tree HEAD)\n> >\n> > > To illustrate this issue, I created a small sample repo, with one\n> > > executable file and one non-executable file. From the output below,\n> > > you can see that the mode in the output from fast-export is the same\n> > > for both files; according to the documentation for fast-import, the\n> > > mode for the executable file should be 100755 instead of 100644.\n> > >\n> > >     $ ls -gG\n> > >     total 2\n> > >     -rwxr-xr-x 1 106 Apr 29 09:13 executable_script.sh*\n> > >     -rw-r--r-- 1  63 Apr 29 09:12 non_executable_file.txt\n> > >\n> > >     $ git fast-export --all\n> > >     blob\n> > >     mark :1\n> > >     data 106\n> > >     #!/bin/bash\n> > >\n> > >     # This is a shell script that should be executable.\n> > >     echo 'The script executed successfully!'\n> > >\n> > >     blob\n> > >     mark :2\n> > >     data 63\n> > >     This file is a simple text file that should not be executable.\n> > >\n> > >     reset refs/heads/dev\n> > >     commit refs/heads/dev\n> > >     mark :3\n> > >     author Doug <41mortimer@gmail.com> 1588167102 -0400\n> > >     committer Doug <41mortimer@gmail.com> 1588167102 -0400\n> > >     data 25\n> > >     Adding some sample files\n> > >     M 100644 :1 executable_script.sh\n> > >     M 100644 :2 non_executable_file.txt\n> > >\n> > > Please let me know if there is any further information I can provide\n> > > about this issue.\n> >\n> > Does Git think that the file is executable? Please run 'git ls-tree\n> > HEAD' to find out.\n> >\n> > > Thank you,\n> > > Doug\n> >\n> > Thanks,\n> > Taylor\nThanks,\nTaylor\n"},{"id":"396990","messageId":"nycvar.QRO.7.76.6.2005041620540.56@tvgsbejvaqbjf.bet","threadId":"53352","inReplyTo":"20200501223240.GG41612@syl.local","subject":"Re: git fast-export not preserving executable permissions?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-05-04T14:23:48Z","receivedAt":"2020-05-04T21:24:48Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 1 May 2020, Taylor Blau wrote:\n\n> If you are using NTFS or FAT32, neither of these filesystems support\n> execute permission bits. (I am certainly not an expert here, but I know\n> that Dscho (cc'd) would be able to answer authoritatively here.)\n\nOn Windows, there are indeed no executable bits. A file is considered\nexecutable if it has a file extension indicating it, e.g. `.exe`.\n\nIn Git for Windows' Bash (which comes from MSYS2), `ls -l` will also\nconsider files whose first line is a hash-bang one (e.g. `#!/bin/sh`) as\nexecutable. This information is however _not_ used by Git.\n\nIf you want to mark a file as executable in Git for Windows, you will have\nto use `git add --chmod=+x <file>`.\n\nCiao,\nJohannes\n"}]}