I have a big project written in Delphi and I want to manage its sources using Git. I created Git repository, which includes my application's sources and 3rd party components. All that stuff is automatically building using msbuild
.
The biggest problem is RES files. Some of them are updated every time I rebuild my application, some are not. Some have *.rc sources, some don't. I can't ignore all res files (.gitignore) because without resources my project will fail to build. Also, I can't include res files - they change from build to build, I don't want to see them in diffs.
What do you do with your *.res files under Git? Any advices?
Welcome to the club. The application .res file in Delphi is a pain in the lower back for everybody using source control. You want to use auto-inc-buildnumber but it messes up your scource control. What I have done is
split the icon and the version resources like this:
{$R *_icon.res}
{$R *._version.res}
disable auto inc of the buildnumber
add a pre-build event to the project that
add the *_icon.res file to source control, it never changes so this is safe
add the .ini file with the version info to source control, it is a text file so it is easy to diff
The tool I have written for generating the version .res file is free software, available here and also from OSDN
I keep my project RES files in git (those that match the name of the dpr).
I believe the only reason the project RES file would change every time you build is if you have increment build number set, which to me either means you need to keep the res in source control or you don't care about the build number so you should turn off that option.
I do also have RES files that I build from RC, which change every compile, so I have a gitignore for *.res and I then add git add -f project.res
for the project RES files
By definition, RES files are compiled RC files. So ideally you should ignore all RES files and commit only RC changes. If it happened somehow that you don't have an RC source for some particular RES file, then add only this "orphan" RES file to git - such files shouldn't change from build to build (cause there is no RC file to generate them from). If for some strange reasons (Delphi, huh) such RES files do change, then you are doomed.
Bottom line: RES files are compilation targets - no different from other binaries (obj,exe,etc)
It's strongly advised to disable the "Auto increment build number" in the project settings, with any kind of version control system. This way it's 'safe' to add the .res files to the repository.
I have been searching for a long time for a way to auto-update the build number in the version info in the project's .res file, but the best thing is to update an extra .rc with the version info. In practice though, I generally update the build number to the current subversion revision number only right before the final build for a release of the binaries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With