git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Next: Jeff King
Message 1 of 7 in “git smudge filter fails”
  1. Stephen MortonMar 9, 2016
  2. Jeff KingMar 10, 2016
  3. Stephen MortonMar 10, 2016
  4. Jeff KingMar 10, 2016
  5. Junio C HamanoMar 10, 2016
  6. Stephen MortonMar 15, 2016
  7. Junio C HamanoMar 15, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.