1

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 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

By the way folks, these commands are for Unix and can be issued in a Git Gui window by selecting "Repository" menu, select 'Git Bash'. The 'cut' command can easily be modified to strip leading sequence number cols 1-5 from traditional Cobol statements. @jthill, I looked long and hard for this solution to uncontrolled source sequence field cols 73-80; thank you so much. This answer deserves to be more widely known among Git users, especially those who may also require '--no-index'.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.