0

For mainframe modernization I'm using git to modify my Cobol programs.

To compare two programs one in Dev stage and another in Prod stage, I would like to compare them only from column 1 to 72.

I tried using git diff, git difftool and vimdiff but I don't know how to customize or set them and replace the default which is 80 to 72.

I tried to find the .vimrc file on my pc but the result is not a success.

Unsuccessfully, I tried to set the tool via vim but that does not work.

Please, could you help me? Regards.

I tried to find the .vimrc file on my pc to set the new parameters but I don't find it I tried to set the tool via vim but that does not work.

2 Answers2

3

You can specify text conversions to use when prepping files for diffing,

echo \*.cob diff=strip73on >>.git/info/attributes

git config diff.strip73on.textconv 'cut -c1-72'

and from then on anything using git's diff core in that clone will ignore those files' line numbers.

jthill
  • 55,082
  • 5
  • 77
  • 137
2

You can extract the first 72 characters of either of the files using cut and compare those (replace file.1 and file.2 with actual paths to the files you want to compare):

COL=72
FILE_A=file.1
FILE_B=file.2
diff --unified -- <(cat "$FILE_A" | cut -c 1-$COL) <(cat "$FILE_B" | cut -c 1-$COL)

If you want to compare side by side, use diff --side-by-side.

svlasov
  • 9,923
  • 2
  • 38
  • 39