1) In retrospect it would obviously have been useful to establish general rules about using the code in advance. Is the code public? Is it available for use by any of the original co-authors without having to include the other authors on future publications? Can it be shared with or without consent from the original co-authors? Any of these rules are fine, they just have to be agreed on in advance.
2) Now that the code was used in a new project I strongly sympathize with the request of your students supervisor. I would be very uncomfortable publishing a paper based on a code that I have no access to. It means that I cannot verify the results in my own paper!
3) In sharing the code with colleagues it is perfectly o.k to restrict future use. You can say ``I'm sharing this code for the purpose of verifying the work on your current project, but if you wish to use it in the future you have to ask permission/include an acknowledgement/add me as co-author/etc. (whatever you and your authors feel is appropriate)".
4) Personally, I am strong believer in open software. If you publish a paper based on a code, the code should be made public. However, this is not a commonly accepted standard, and restricted and proprietary codes are common in many areas of science.