z/OS Tools & Language

Expand all | Collapse all

Does "git checkout" use the .gitattributes file?

  • 1.  Does "git checkout" use the .gitattributes file?

    Posted 04-03-2018 02:28

    Being no GIT expert, I can only assume that GIT stores it data internally in ASCII. I’ve come to this conclusion because of the information in the .gitattributes file eg

    * working-tree-encoding=ibm-1047 git-encoding=iso8859-1
    .gitattributes working-tree-encoding=iso8859-1 git-encoding=iso8859-1

    Through trial and error I’ve found that its the “GIT ADD” that uses the info in .gitattributes.

    But what about “GIT CHECKOUT” ? If I delete .gitattributes, shouldn’t the file come back in ASCII ? As there is nothing telling GIT is should convert it to EBCDIC.

    This doesn’t seem to be the case. But I don’t understand why not.

    Regards,
    Gary



  • 2.  RE: Does "git checkout" use the .gitattributes file?

    Posted 04-03-2018 08:17

    You have to remove the existing EBCDIC files after removing the .gitattributes files and then checkout again. It’s a slightly tricky operation. Here’s an example:

    bash-4.3$ git clone git@github.com:zorts/hello_world.git
    Cloning into 'hello_world'...
    bash-4.3$ cd hello_world/
    bash-4.3$ ls -alT
    total 258
                        drwxr-xr-x   3 TSJLC    PDUSER      8192 Apr  3 08:12 .
                        drwxr-xr-x   3 TSJLC    PDUSER      8192 Apr  3 08:12 ..
                        drwxr-xr-x   8 TSJLC    PDUSER      8192 Apr  3 08:12 .git
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER       316 Apr  3 08:12 .gitattributes
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER        10 Apr  3 08:12 .gitignore
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER       642 Apr  3 08:12 Makefile
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER      1206 Apr  3 08:12 README.md
    t IBM-1047    T=on  -rwxr-xr-x   1 TSJLC    PDUSER       257 Apr  3 08:12 allocate.sh
    t IBM-1047    T=on  -rwxr-xr-x   1 TSJLC    PDUSER        56 Apr  3 08:12 cleanup.sh
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER       363 Apr  3 08:12 from_pds.jcl
    t IBM-1047    T=on  -rwxr-xr-x   1 TSJLC    PDUSER       370 Apr  3 08:12 from_pds.sh
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER       176 Apr  3 08:12 hello.c
    t IBM-1047    T=on  -rwxr-xr-x   1 TSJLC    PDUSER        91 Apr  3 08:12 listd.sh
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER      1110 Apr  3 08:12 to_pds.jcl
    t IBM-1047    T=on  -rwxr-xr-x   1 TSJLC    PDUSER       466 Apr  3 08:12 to_pds.sh
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER       345 Apr  3 08:12 util.c
    t IBM-1047    T=on  -rw-r--r--   1 TSJLC    PDUSER       138 Apr  3 08:12 util.h
    bash-4.3$ git checkout -b noattr
    Switched to a new branch 'noattr'
    bash-4.3$ git rm .gitattributes
    rm '.gitattributes'
    bash-4.3$ git commit -m "remove the .gitattributes file"
    [noattr 011db82] remove the .gitattributes file
     1 file changed, 7 deletions(-)
     delete mode 100644 .gitattributes
    bash-4.3$ rm *
    bash-4.3$ git reset --hard HEAD
    HEAD is now at 011db82 remove the .gitattributes file
    bash-4.3$ git status
    On branch noattr
    nothing to commit, working directory clean
    bash-4.3$ ls -alT
    total 242
                        drwxr-xr-x   3 TSJLC    PDUSER      8192 Apr  3 08:13 .
                        drwxr-xr-x   3 TSJLC    PDUSER      8192 Apr  3 08:12 ..
                        drwxr-xr-x   8 TSJLC    PDUSER      8192 Apr  3 08:13 .git
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER        10 Apr  3 08:12 .gitignore
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER       642 Apr  3 08:13 Makefile
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER      1206 Apr  3 08:13 README.md
    t ISO8859-1   T=on  -rwxr-xr-x   1 TSJLC    PDUSER       257 Apr  3 08:13 allocate.sh
    t ISO8859-1   T=on  -rwxr-xr-x   1 TSJLC    PDUSER        56 Apr  3 08:13 cleanup.sh
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER       363 Apr  3 08:13 from_pds.jcl
    t ISO8859-1   T=on  -rwxr-xr-x   1 TSJLC    PDUSER       370 Apr  3 08:13 from_pds.sh
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER       176 Apr  3 08:13 hello.c
    t ISO8859-1   T=on  -rwxr-xr-x   1 TSJLC    PDUSER        91 Apr  3 08:13 listd.sh
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER      1110 Apr  3 08:13 to_pds.jcl
    t ISO8859-1   T=on  -rwxr-xr-x   1 TSJLC    PDUSER       466 Apr  3 08:13 to_pds.sh
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER       345 Apr  3 08:13 util.c
    t ISO8859-1   T=on  -rw-r--r--   1 TSJLC    PDUSER       138 Apr  3 08:13 util.h
    bash-4.3$