Re: Is there a way to have a local version of a header file?
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Mar 18, 2017, 14:48 UTC
- Message-ID
- <CACBZZX5FMdjuxxNru+XfTQdSXEQ_b0OP2rngGZLf1sSHR_D8Ng@mail.gmail.com>
- In-Reply-To
- <nycvar.QRO.7.75.62.1703180724490.3797@qynat-yncgbc>
On Sat, Mar 18, 2017 at 3:29 PM, David Lang <david@lang.hm> wrote:
Show 15 quoted lines
> for an embedded project built inside the Arduino IDE, (alternate firmware > for a home automation project) there is a need to set a number of parameters > that we really don't want in the main repo (wifi network IDs/passwords) > > right now, we have these things set as #defines in a header file. > > We need to distribute a base version of this file for new people to get > started. > > Is there any way to have git define a file in such a way that if it doesn't > exist in the worktree it gets populated, but if it does exist it doesn't get > overwritten? (as I type this, I'm thinking a trigger may work, but we need > it to work on Linux, Windows and OSX) > > Any thoughts on a sane way to handle this situation?
There's no sane way to do what you're describing without renaming the file.
But the sanest way to do this is to have a config.h.example
Then you have "/config.h" in the .gitignore file.
And you tell the users to copy the *.example file to *.h, and your program then includes the *.h file.
If you wanted to provide defaults you could just #include the config.h.example first, so #defines in the *.h file would clobber those in the *.example.