4

I have a git project that contains mostly z/OS COBOL source code.

When I clone it onto my z/OS system using:

git clone myproject

I noticed that all of the cloned files are in ASCII (ISO8859-1). Is there a way to keep the working tree in EBCDIC 1047 on z/OS?

chtag -p yields the following:

t ISO8859-1    T=on  hello.cob

In the meantime, I am currently converting the files using iconv, but is there a better way?

1 Answers1

4

For a long time Git has had the gitattributes which is the starting point for the answer to this question. You can read more about it in the Git docs, here.

z/OS behaves a bit different in this aspect compared to what you will find in the documentation. There is a reason for it though. While the Git docs mention working-tree-encoding you should be using zos-working-tree-encoding to specify IBM-1047 instead. This was originally developed by Rocket but has since been taken over into other versions as well (see Mike's comment below). It is documented here: https://docs.rocketsoftware.com/bundle/openappdev_ug_20/page/brb1683803214347.html

I don't know this for sure but my understanding is that this way a Git checkout on a non-z/OS host doesn't run into issues when it is trying to convert your files into an EBCDIC code page. If you are sure that your project won't be checked out on a non-z/OS system you could also use working-tree-encoding.

A sample .gitattributes file for your case would look like this:

*.cob        zos-working-tree-encoding=ibm-1047

The .gitattributes file must be in UTF-8 (or ISO8859-1 but try to stick to UTF-8.)

Note: You might find some examples from IBM which also include the git-encoding parameter to specify how Git handles files internally. This should not be used anymore and defaults to UTF-8 (also on z/OS). It is described by Rocket here.

Note 2: Out of personal experience IBM-1047 is often times not enough as it doesn't include the € sign which is why we tend to use the national code page like ibm-1141 (over here in Germany). For the rest of the world this is likely not interesting.

Crosswind
  • 940
  • 1
  • 10
  • 26
  • Upvoted, but all EBCDIC sets I ever used, including 1047, most certainly do have the dollar sign at `5B`. – jthill Jun 20 '23 at 07:42
  • @jthill thanks for pointing this out. I double checked and that is only an issue with the € sign which is converted to 9F. I’ll remove it from the answer. – Crosswind Jun 21 '23 at 09:45
  • 1
    Good answer. I would definitely recommend the zos-working-tree-encoding=ibm-1047 over just setting the working-tree-encoding because then it should 'just work' on the different platforms you might want to view the code (github, gitlab, windows, linux, z/OS, etc) and I don't think there is any downside. Note that the enhancements are now in the official 'dev' line and available to anyone - not restricted to Rocket. You can also get the Open Source code at: https://github.com/ZOSOpenTools/gitport – mike Jun 21 '23 at 18:29