git smudge filter fails
- From
Stephen Morton <stephen.c.morton@gmail.com>
- Date
- Mar 9, 2016, 18:29 UTC
- Message-ID
- <CAH8BJxHwxp2BtzGBqi6J24Kh0TTGEdCx=-Scu+bx5N-ZVpBZNQ@mail.gmail.com>
A git smudge filter, at least one that relies on the results from 'git log' does not seem to work on file A when doing a 'git update' from a revision where file A doesn't exist to a revision where it does exist.
Below is a simple recipe to reproduce.
This appears to me to be a bug. If not, why is it expected and is there anything I can do to work around this behaviour?
Steve
mkdir git_test cd git_test/ git init . touch bar.c git add . git commit -am "Initial commit. foo.c not here yet." git tag no_foo
touch foo.c git add . git commit -am "Add foo, no content" echo 'Date is $Date$' >> foo.c git commit -am "Add date to foo.c" echo 'foo.c filter=dater' > .git/info/attributes git config --local filter.dater.smudge 'myDate=`git log --pretty=format:"%cd" --date=iso -1 -- %f`; sed -e "s/\(\\$\)Date[^\\$]*\\$/\1Date: $myDate \\$/g"' git config --local filter.dater.clean 'sed -e "s/\(\\$\)Date[^\\$]*\\$/\1Date\\$/g"' rm -f foo.c git checkout -- foo.c cat foo.c # observe keyword expansion
git checkout no_foo git checkout master cat foo.c #observe keyword expansion lost