Skip to main content
Lionel Dyck
Participating Frequently
Feb 1, 2023 8:49 AM UTC
Question

git 2.26.

Something changed in git in terms of file encoding.

These files were created using this code:

cmd = 'cd' localrep'/'zigirep ,
   '&& git show' hcommit':'element ,
   '>' file

where localrep/zigirep, hcommit, element and file are all variables.

This is what I have on my work system for this use case using git version 2.26.2-78

t IBM-1047 T=on -rw-rw-rw- 1 SPLBD SYS1 1875 Feb 1 05:03 CHGSTR

But with git version 2.26.2-84 I get this:

t ISO8859-1 T=on -rw-rw-rw- 1 LBDYCK ZOWEDEV 1875 Feb 1 08:06 CHGSTR

To summarize this - with git 2.26.2-27 the git show generated file is tagged as IBM-1047 and then with git 2.26.2-84 it is now tagged as ISO8859-1.

Why the change and how can I control it?

    14 replies

    Gary Freestone
    Participating Frequently
    Apr 25, 2023 7:27 AM UTC

    Something changed in git in terms of file encoding.

    These files were created using this code:

    cmd = 'cd' localrep'/'zigirep ,
       '&& git show' hcommit':'element ,
       '>' file

    where localrep/zigirep, hcommit, element and file are all variables.

    This is what I have on my work system for this use case using git version 2.26.2-78

    t IBM-1047 T=on -rw-rw-rw- 1 SPLBD SYS1 1875 Feb 1 05:03 CHGSTR

    But with git version 2.26.2-84 I get this:

    t ISO8859-1 T=on -rw-rw-rw- 1 LBDYCK ZOWEDEV 1875 Feb 1 08:06 CHGSTR

    To summarize this - with git 2.26.2-27 the git show generated file is tagged as IBM-1047 and then with git 2.26.2-84 it is now tagged as ISO8859-1.

    Why the change and how can I control it?

    I thought I finally understood this issue but alas it keeps on keeping on. 

    Everything thing I said in my previous post is true BUT.....

    Only for files committed using Git 2.26 onward.   Files that were committed before 2.26 were committed as ASCII meaning that the current "iconv -f ISO8859-1 -t IBM1047"  will work fine as these files are not UTF-8 format.  It's only files committed to Git in UTF-8 format that have the issue. 

    Question for Rocket.  Is there any way of telling whether the files committed in the Git repository are encoded in ASCII or UTF-8.   ????

    Benjamin Maloy
    Rocketeer
    Apr 25, 2023 8:59 AM UTC

    Something changed in git in terms of file encoding.

    These files were created using this code:

    cmd = 'cd' localrep'/'zigirep ,
       '&& git show' hcommit':'element ,
       '>' file

    where localrep/zigirep, hcommit, element and file are all variables.

    This is what I have on my work system for this use case using git version 2.26.2-78

    t IBM-1047 T=on -rw-rw-rw- 1 SPLBD SYS1 1875 Feb 1 05:03 CHGSTR

    But with git version 2.26.2-84 I get this:

    t ISO8859-1 T=on -rw-rw-rw- 1 LBDYCK ZOWEDEV 1875 Feb 1 08:06 CHGSTR

    To summarize this - with git 2.26.2-27 the git show generated file is tagged as IBM-1047 and then with git 2.26.2-84 it is now tagged as ISO8859-1.

    Why the change and how can I control it?

    Hey @Gary Freestone

    Thanks for bringing this back up. Unfortunately, there is no metadata or anything like that to indicate the encoding of the files in the index. You can check out the repo with no .gitattributes and you will get all of the content of the index 'as is' upon cloning.

    To that end, what are the contents of your .gitattributes file?

    Some background info that may be useful: If you have a zos-working-tree-encoding specified for a file, then it will be converted to UTF-8 when it is uploaded to the index. If you do not have a zos-working-tree-encoding specified, the file will be uploaded to the index without any conversion.

    Gary Freestone
    Participating Frequently
    Apr 25, 2023 7:11 PM UTC

    Something changed in git in terms of file encoding.

    These files were created using this code:

    cmd = 'cd' localrep'/'zigirep ,
       '&& git show' hcommit':'element ,
       '>' file

    where localrep/zigirep, hcommit, element and file are all variables.

    This is what I have on my work system for this use case using git version 2.26.2-78

    t IBM-1047 T=on -rw-rw-rw- 1 SPLBD SYS1 1875 Feb 1 05:03 CHGSTR

    But with git version 2.26.2-84 I get this:

    t ISO8859-1 T=on -rw-rw-rw- 1 LBDYCK ZOWEDEV 1875 Feb 1 08:06 CHGSTR

    To summarize this - with git 2.26.2-27 the git show generated file is tagged as IBM-1047 and then with git 2.26.2-84 it is now tagged as ISO8859-1.

    Why the change and how can I control it?

    @Benjamin Maloy thanks for replying. 

    I'm not talking about "git checkout" nor "git clone".  Both of these commands bring the source code from Git to the working directory correctly.  It doesn't matter to these commands whether the code is encoded in Git as UTF-8 (Git 2.26 and above) or encoded as ASCII (releases of Git prior to 2.26) the working directory files always end up with the correct characters.

    The issue is with "Git Show" and the fact that when bringing back source code it always assumes it was encoded in Git as ASCII.  This was true prior to Rocket's Git 2.26 release. But since 2.26 its been encoded in UTF-8.

    So why do Checkout and Clone work correctly and Show not ?

    I don't think my .gitattributes has anything to do with it. But you asked so here it is:

    #                                                                         
    # Default zGit .gitattributes file specifying the attributes of some      
    # known file names                                                        
    #                                                                         
    #                                                                         
    # This file is copied to .git/info/attributes when a zGit repo is created 
    #                                                                         
    #                                                                         
                                                                              
    *              zos-working-tree-encoding=ibm-1047                         
    .gitattributes zos-working-tree-encoding=iso8859-1                        
    .gitignore     zos-working-tree-encoding=iso8859-1                        
                                                                              
    *.mpg          binary                                                     
    *.mov          binary                                                     
    *.mp3          binary                                                     
    *.mp4          binary                                                     
    *.wav          binary                                                     
    *.png1         binary                                                     
    *.whl          binary                                                     
                                                                              
    # Archives                                                                
                                                                              
    *.7z           binary                                                     
    *.br           binary                                                     
    *.gz           binary                                                     
    *.tar          binary                                                     
    *.zip          binary                                                     
                                                                              
    # Documents                                                               
                                                                              
    *.pdf          binary                                                     
                                                                              
    # Images                                                                  
                                                                              
    *.gif          binary                                                     
    *.ico          binary                                                     
    *.jpeg         binary                                                     
    *.jpg          binary                                                     
    *.pdf          binary                                                     
    *.png          binary                                                     
    *.psd          binary                                                     
    *.webp         binary                                                     
                                                                              
    # Fonts                                                                   
                                                                              
    *.woff2        binary                                                     
                                                                              
    # Other                                                                   
                                                                              
    *.exe          binary                                                     
    *.md           zos-working-tree-encoding=UTF-8                            

    Benjamin Maloy
    Rocketeer
    Apr 26, 2023 10:40 AM UTC

    Something changed in git in terms of file encoding.

    These files were created using this code:

    cmd = 'cd' localrep'/'zigirep ,
       '&& git show' hcommit':'element ,
       '>' file

    where localrep/zigirep, hcommit, element and file are all variables.

    This is what I have on my work system for this use case using git version 2.26.2-78

    t IBM-1047 T=on -rw-rw-rw- 1 SPLBD SYS1 1875 Feb 1 05:03 CHGSTR

    But with git version 2.26.2-84 I get this:

    t ISO8859-1 T=on -rw-rw-rw- 1 LBDYCK ZOWEDEV 1875 Feb 1 08:06 CHGSTR

    To summarize this - with git 2.26.2-27 the git show generated file is tagged as IBM-1047 and then with git 2.26.2-84 it is now tagged as ISO8859-1.

    Why the change and how can I control it?

    Hey @Gary Freestone

    In response to "The issue is with "Git Show" and the fact that when bringing back source code it always assumes it was encoded in Git as ASCII.  This was true prior to Rocket's Git 2.26 release. But since 2.26 its been encoded in UTF-8.":

    The .gitattributes file will dictate the encoding of a file in the index, which is what the 'git show' command will display. I see from your .gitattributes file that all files have a zos-working-tree-encoding specified. This means that in the index, the files are stored as UTF-8. Hence, when you use the 'git show' command to check the contents of the index, the files will be encoded as UTF-8. 

    You mentioned that you are comparing this behavior to git before 2.26. As you mentioned, before git for z/OS version 2.26, you could upload files to the index as ISO8859-1, in which case the 'git show' command would display an ISO8859-1 file.

    Does this explain the difference in the behavior of the 'git show' command?

    Indeed, if the files are UTF-8 in the index, you may have trouble converting to EBCDIC if you have multibyte characters in the file.