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

Re: How to simulate a real checkout to test a new smudge filter?

From
JSjohn smith <wempwer@gmail.com>
Date
Sep 9, 2016, 22:03 UTC
Message-ID
<CAKmQUfafCP6ZwUm7Ec5n2PzvNzBHnFWEJL1usMTFB6Ef0m=8pw@mail.gmail.com>
In-Reply-To
<e17a88cd-2de7-dc84-2262-743e82d8b047@gmail.com>
On 9/8/16, Jakub Narębski <jnareb@gmail.com> wrote:
Show 23 quoted lines
> W dniu 06.09.2016 o 23:01, john smith pisze:
>
>> I'd prefer smudge/clean filters instead of `make' scripts etc. to
>> convert template dotfiles into something usable and back because
>> filters:
>>
>> 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
>> point 2.
>
> Couldn't you use post-checkout hook plus clean filter instead of
> clean/smudge filter pair, if the smudge part depends on the branch?
>
> Or make post-checkout hook invoke smudge filter... though
> `git cat-file --filters` is not in any released version, I think...

I moved smudge-filter functionality to post-checkout hook and only left clean filter. Now post-checkout hooks is called every time when changing branches but it's not working together with clean filter when changing branches. For example, when I have this on master in bash/.bashrc:

export EMAIL="@EMAIL@"

After moving to `work' it becomes this thanks to post-checkout hook which replaces @EMAIL@ with correct definition:

export EMAIL="work@address.com"
But when I move to `home' branch from `work' I still get this:
export EMAIL="work@address.com"

post-checkout didn't work here because it can't see @EMAIL@ part in bash/.bashrc because clean filter has not been run. I need to run this single command to force `clean' filter to run to replace work@address.com with @EMAIL@ and let post-checkout replace it with correct value:

git checkout .
And now I get the correct definition:
export EMAIL="home@address.com"

So it seems that clean filter is only run when checking out paths but not when checking out branches. Is my thinking correct?

-- 
<wempwer@gmail.com>
Previous: Jakub NarębskiNext: Junio C Hamano
Message 6 of 11 in “How to simulate a real checkout to test a new smudge filter?”
  1. john smithSep 6, 2016
  2. Torsten BögershausenSep 6, 2016
  3. john smithSep 6, 2016
  4. Michael J GruberSep 7, 2016
  5. Jakub NarębskiSep 8, 2016
  6. john smithSep 9, 2016
  7. Junio C HamanoSep 9, 2016
  8. john smithSep 9, 2016
  9. Junio C HamanoSep 9, 2016
  10. Jakub NarębskiSep 10, 2016
  11. john smithSep 10, 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.