1

I am establishing Git environment on our project. The problem is, our project includes generated SW package(c files) which contains Generation Time Info within comment-out. Therefore everytime we generate the SW package, contents of every file is changed even though there is no effective change. So I don't want to track commented-out parts of c files. Is there any way?

Zombo
  • 1
  • 62
  • 391
  • 407
  • 3
    I think you can add the file extension like (.sw) into the .gitignore file. https://help.github.com/articles/ignoring-files – Ye Lin Aung Jan 29 '13 at 01:33
  • 3
    Why is the generated code getting regenerated all the time when there are no changes? If you can find a way to only make it regenerate when there is a change that would be your best bet. If necessary, contact the creator of the code-generator and see if they can help because it sounds like they are the ones at 'fault' here so to speak. – Brandon Moore Jan 29 '13 at 01:33
  • That is, I'm assuming these files have code that should be included in source control (and I was also assuming they ended with ".c"). If that's not the case then obviously mgpyone's suggestion is the way to go. – Brandon Moore Jan 29 '13 at 01:35
  • 8
    Adding to the comments here, generated files usually are not added in to source control, because they could be generated by anyone who is cloning the repo... Much like `bin`, `gen`, `*.dll` etc. not being added to the repository... – Hari Pachuveetil Jan 29 '13 at 01:37
  • I understand that generated files usuall are not version controlled. But our project is so huge that it takes about 40minutes when we generate sw package and compile again(I mean, when we generate sw package, we have to have full-compile) – user2019990 Jan 29 '13 at 01:45
  • It's still better to have a one-time 40 minute delay when somebody checks the project out, rather than including a ton of generated content in Git. – user229044 Jan 29 '13 at 02:17

2 Answers2

0

The normal solution is to add the sw/ directory to the list of elements ignored in a .gitignore file:

sw/

But if you need those generated files because of time constraints on checkout, then you could first make them "assume-unchanged":
See "git update-index --assume-unchanged on directory".
That way, those files would not be displayed in git status, even if changed;

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

If you really want to avoid the long generation times for everyone who checks out the repo, another option would be to strip the comments from the generated files, or even strip only the timestamp comments to avoid spurious changes. Of course, this has the issue that the sources and generated versions could potentially become out-of-sync.

If the comments always take a single line and follow a simple pattern that's easy to regex for (which seems likely), this shouldn't be too hard with grep or sed or whatever.

If not, you can supposedly strip all comments without changing anything else with gcc -fpreprocessed -dD -E file.c, though there are some other answers on that page saying that doesn't quite always work and giving a few other options.

Community
  • 1
  • 1
Danica
  • 28,423
  • 6
  • 90
  • 122