3
The problem I’m facing is this::
The C application has an option where the build date of the application is displayed. To prevent the developer from managing the application before the current day we avoid using the preprocessing command DATE in any file because it does not always occur the rebuild, files already compiled are not recompiled.
Then we included in the pre-build script a script that simply creates a file with a current date record in a value of #define. This file is generated whenever there is a new build.
example of the generated file content (data_compilation. h):
#define DATA_COMPILACAO "20/02/19"
If the day changes, the #define is changed. Otherwise, the file remains unchanged except by file timestamp.
When I run git status in this scenario with no value change from #define, the file has no real changes - just a file timestamp update.
There is the possibility to include the file in . gitignore but would like to know if there is another way to configure Git to ignore file timestamp changes.
Is there a way to set up git for this? How could I handle this situation?
Thanks for the help.
If I understand correctly, add the file that is changed to the
.gitignore
wouldn’t solve your problem??– Gabriel Hardoim
Can you explain why there is such a date and time change in the code, please? If you are not changing the code, it needs to exist?
– egomesbrandao
From what you explain, this file must be a file generated by some build script - maybe to assign version, or something like that. So, my recommendation is that all generated files - including this one - stay on
.gitignore
– Leonardo Alves Machado
@Gabrielhardoim adding the file to . gitignore will prevent the file from being added to the commit in any situation. What I am looking for is a way of ignoring amendments based on some form of rule. Only important changes that do not involve changing the file timestamp for example.
– Wallan Rocha
@egomesbrandao There is a change because the pre-build script is configured to generate a file containing the current date. This approach was decided instead of using a pre-processing command such as DATE to prevent the developer generating the build from not generating an application with the old date. (it may occur that the developer does not recompile the file with the DATE, understands?)
– Wallan Rocha
What is this DATE file for? For version number?
– egomesbrandao
@Leonardoalvesmachado I understand. was the suggestion of Gabrielhardoim too. I will adopt this suggestion for now. I’ll keep looking for a way to bypass file timestamp changes, there must be some way. Thanks to all comments so far. ^^
– Wallan Rocha
@egomesbrandao there is no file with the DATE. What I mentioned above was that nay use the approach of a file containing DATE. Instead, we use another approach, the pre-build script creates a file containing the #define of the current date. The problem is that even if the date doesn’t change, the date of the archive gets a different timestamp.
– Wallan Rocha
What I want to know is more about this process, what the purpose... Why I think it is a matter of concept: In source code, any change must be registered, you are changing the code, but from what I understand this change is irrelevant... So if it’s irrelevant, why does it happen? I think this pre-build process should be changed. Can you talk more about it, please, so we can help you better?
– egomesbrandao
@egomesbrandao I edited the description with more details of the process. Already taking into account the suggestion to add the file in . gitignore.
– Wallan Rocha
@Wallanrocha do not remember very well the type Date in C, but he does not have the schedule, too? Wouldn’t it be expensive to compare only the date part? Well, I don’t quite understand... But giving a hint, if the previous paragraph does not work... The build should be performed in a centralized location, in this location, would be stamped the binary version. Since you use Git, it would be interesting to use the Git version, and that would no longer be necessary. This also if you are in a continuous integration process, the versions that you do not use, or that do not go into production plays out.
– egomesbrandao
@egomesminded the DATE no time. Yes, I am entering only the date. I understood that the script will recreate the file even if it does not change the date, so your suggestion is very valid, I will search for a way to avoid (already in the pre-build script) that the file is recreated when do not change the date. Thanks for the suggestion, I’ll shift the search focus to the script, and leave git configured with . gitignore for now.
– Wallan Rocha
@Wallanrocha Take a look at this: https://stackoverflow.com/a/16244970/10226260 I hope it helps you
– Gabriel Hardoim