Open-source Languages & Tools for z/OS

 git commit opens unreadable text in vi

Jump to Best Answer
Leonid Tepliakov's profile image
Leonid Tepliakov posted 11-15-2021 06:23

Hi everyone,
I am on git version 2.14.4_zos_b09 under USS.

When I try to issue git commit without parameters I am getting unreadable text in vi.

I guess it happens because it shows me the text in iso8859-1. Can it be switched it to use ibm-1047?

Vladimir Ein's profile image
ROCKETEER Vladimir Ein Best Answer
Hi Leonid,

Have you set up environment variables as required for auto-conversion? As long as you have these I believe you don't need Git output to be specifically encoded as IBM-1047 - file tagging and auto-conversion will do the trick.

export _BPXK_AUTOCVT=ON
export _CEE_RUNOPTS='FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)'
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt
export _TAG_REDIR_ERR=txt

I've just tried it and it works fine for me with vi.

Regards,
Vladimir
Leonid Tepliakov's profile image
Leonid Tepliakov

Thank you, Vladimir it works for me!

I think I still need ibm-1047 because  I  save in git sources from MVS data sets. They are EBCDIC.

Vladimir Ein's profile image
ROCKETEER Vladimir Ein
Hi Leonid,

Encoding of the files you store in Git is a different matter.

First of all, the files that you commit to Git need not necessarily be EBCDIC, even if they come from data sets. You probably copy data set members to USS filesystem to store them in Git, and vice versa. It's possible to translate the files between EBCDIC and ASCII as you copy them, but this depends on the tools you use. For example, the cp command in USS would do it like this:

# copy to USS
cp -O c=ISO8859-1 "//'MY.DATA.SET(MEMBER)'" ascii-file.txt

# copy back to a data set
cp -O u ascii-file.txt "//'MY.DATA.SET(MEMBER)'"

Then, even if your files in USS are EBCDIC, you can tell Git to convert them from EBCDIC to the encoding used by the repo (which is usually UTF-8, but it depends). Use the zos-working-tree-encoding attribute in .gitattributes for that. Please refer to Git for z/OS Release Notes for more details. You can find them by logging in to the Rocket Community portal, selecting the category z/OpenSource on the left panel, and entering 'Git' in the filter field on the right.

Please note that Git 2.14.4 is outdated. The most recent version of Git is 2.26.2, and there are important differences between these two versions in how they handle file encodings. You might want to consider upgrading to 2.26 now so that you don't need to migrate your repositories later. Git 2.26 is only available via Miniconda.

Another important thing to note is that our tools require automatic character conversion to be enabled. The variables I listed in my previous post need to be always active; otherwise file tags and encodings won't work properly.

Regards,
Vladimir