views:

376

answers:

6

Hi!

I have a big project written in Delphi and I want to manage it's 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 not. Some have *.rc sources, some doesn'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 are changed form build to build, I don't want to see them in diffs.

What do you do with your *.res files under Git? Any advices?

A: 

I don't know GIT, but under SVN I simply only "SVN ADD" the few that matter, and not the automatically generated ones. Since unversioned files are excluded from diffs, that's taken care off too then.

Marco van de Voort
+1  A: 

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)

ygrek
In Delphi, the project's RES file is different that other binaries, it does not have a corresponding RC and it contains information found in no other place, like the icon and version numbers
jasonpenny
I see. So you are doomed (Delphi ftw!) to jump through the hoops, other answers provide detailed instructions :)
ygrek
A: 

Could you:

  • ignore all .res files
  • generate the .res files that can be generate (compiling the resources script .rc files)
  • add only the .res files without .rc files to generate them: if you had specified in a .gitignore that they are to be ignored, then adding them is ok: they won't show up in the diff.
VonC
+4  A: 

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

jasonpenny
Thanks for the tip, but I have 25+ components with sources (and with damn res files). It will take a lot of time to find out what res files are changed and what aren't. But the biggest problem is that some res must be included (so I do `git add -f`) and are changed every time I rebuild components.
Frantic
Finally did this. It took a LOT of time, but I'm happy with results.
Frantic
+2  A: 

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.

Stijn Sanders
+5  A: 

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 projec that
    • increments the build number in a .ini file corresponding the project
    • generates a .rc file with the version info from the .ini file
    • compiles a .res file from the .rc file
  • 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.

dummzeuch