git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git fast-export not preserving executable permissions?

From
DGDoug Glidden <41mortimer@gmail.com>
Date
May 1, 2020, 13:35 UTC
Message-ID
<CAHTRwmhhQCs4i04atAK66REiFJP_9e910MoYMt9iyu2v6S2jVw@mail.gmail.com>
In-Reply-To
<20200429184909.GE83442@syl.local>
Taylor,

Thanks for your response! It looks like git does not actually recognize the file as executable:

    $ git ls-tree HEAD
    100644 blob 7d2f57b2381766924e1e4ffcc62615c637bbd784    executable_script.sh
    100644 blob d1d7cf309e091f54f268503b31653d8eba42fe88
non_executable_file.txt

Now you have me wondering if the real problem here is that I'm working in git-bash on a Windows machine, which means the file permissions aren't completely native. I'm going to run a similar experiment in a native Linux environment and see if I get the same results. I'll let you know what I find.

Thanks, Doug

On Wed, Apr 29, 2020 at 2:49 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 87 quoted lines
>
> Hi Doug,
>
> On Wed, Apr 29, 2020 at 09:36:31AM -0400, Doug Glidden wrote:
> > Hello Git world!
> >
> > I have run into an issue that I cannot seem to resolve with git
> > fast-export. When running a fast-export on a repo that contains
> > scripts with executable permissions (e.g. a gradlew script), the
> > resulting export does not properly reflect the executable permissions
> > on the script files.
>
> Interesting. fast-import and fast-export both understand executable
> modes (although Git only understands the modes 644 and 755 for blobs),
> so this should be working.
>
> I can not reproduce the issue as-is. Round-tripping a fast-import and
> fast-export preserves executable bits for me:
>
>   #!/bin/bash
>
>   set -e
>
>   rm -rf repo client
>
>   git init -q repo
>   git init -q client
>
>   (
>     cd repo
>     printf "x" >x
>     printf "y" >y
>     chmod +x x
>     git add x y
>     git commit -q -m "initial commit"
>   )
>
>   git -C repo fast-export HEAD | git -C client fast-import
>
>   diff -u <(git -C repo ls-tree HEAD) <(git -C client ls-tree HEAD)
>
> > To illustrate this issue, I created a small sample repo, with one
> > executable file and one non-executable file. From the output below,
> > you can see that the mode in the output from fast-export is the same
> > for both files; according to the documentation for fast-import, the
> > mode for the executable file should be 100755 instead of 100644.
> >
> >     $ ls -gG
> >     total 2
> >     -rwxr-xr-x 1 106 Apr 29 09:13 executable_script.sh*
> >     -rw-r--r-- 1  63 Apr 29 09:12 non_executable_file.txt
> >
> >     $ git fast-export --all
> >     blob
> >     mark :1
> >     data 106
> >     #!/bin/bash
> >
> >     # This is a shell script that should be executable.
> >     echo 'The script executed successfully!'
> >
> >     blob
> >     mark :2
> >     data 63
> >     This file is a simple text file that should not be executable.
> >
> >     reset refs/heads/dev
> >     commit refs/heads/dev
> >     mark :3
> >     author Doug <41mortimer@gmail.com> 1588167102 -0400
> >     committer Doug <41mortimer@gmail.com> 1588167102 -0400
> >     data 25
> >     Adding some sample files
> >     M 100644 :1 executable_script.sh
> >     M 100644 :2 non_executable_file.txt
> >
> > Please let me know if there is any further information I can provide
> > about this issue.
>
> Does Git think that the file is executable? Please run 'git ls-tree
> HEAD' to find out.
>
> > Thank you,
> > Doug
>
> Thanks,
> Taylor
Previous: Taylor BlauNext: Taylor Blau
Message 3 of 6 in “git fast-export not preserving executable permissions?”
  1. Doug GliddenApr 29, 2020
  2. Taylor BlauApr 29, 2020
  3. Doug GliddenMay 1, 2020
  4. Taylor BlauMay 1, 2020
  5. Johannes SchindelinMay 4, 2020
  6. Torsten BögershausenApr 30, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.