On 9/6/16, Torsten Bögershausen <tbo...@web.de> wrote:
> On 06.09.16 19:47, john smith wrote:
>> I am looking for a way to force smudge filter to run by simulating a
>> real life checkout. Let's say I just created a new branch and did not
>> modify any files but want to test my new smudge filter. According to
>> some answers such as
>> it should be possible by running:
>> git checkout HEAD --
>> but in doesn't work with git 2.9.0. Method suggested in accepted
>> answer here
>> works but I don't like because it seems fragile. Is there a safe way
>> to do what I want to do in Git still today?
> It depends what you mean with "safe way".
I want to store all my dotfiles in a single repoitory. The problem is
that that some specific pieces of these files are different on
different machines. I have a special .conf file that is different on
every branch and contains machine-specific definitions of some
variables such as EMAIL or SMTP server. In my smudge filter I call a
script which parses .conf file and replace all template variable
definitions saved in the given file with correct definitions. For
example in my ~/.bashrc I have this on all branches:
and in my .conf file on `home' branch
and on `work' branch:
And in .gitattributes on both branches:
I also have single `master' branch that only contains template
dotfiles and no .conf. When setting up a new machine I could just
create a new branch off master branch and add a new .conf.
In turn, clean filter replace all correct definitions in the given
dotfiles back into template definitions.
I'd prefer smudge/clean filters instead of `make' scripts etc. to
convert template dotfiles into something usable and back because
1. could be run automatically
2. do not modify files as shown by `git show HEAD:<file>' and
therefore no files are reported as modified by git status and also
there are not conflicts when merging master into work/home branch.
I have problems because with point 1 because apparently smudge filter
is not run automatically every time when branch is changed if files
listed in .gitattributes do not change. As the last resort I could
force smudge/clean filter to run just to keep advantage specified in