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

problem with not being able to enforce git content filters

From
SBStas Bekman <stas@stason.org>
Date
Oct 16, 2018, 20:36 UTC
Message-ID
<5d4966c8-8171-9a0a-5120-f7c151c2b81f@stason.org>
Hi,
TL;DR

Our open source project dev team has a continuous problem with git content filters, because developers don't always have them configured.

We need a way for git to support content filters w/o using user's .gitconfig. Otherwise it leads to an inconsistent behavior and messed up git checkouts.

=================================================
Full story:

We use a version of the nbstripout content filter (https://github.com/kynan/nbstripout), which removes user-specific information from the jupyter notebooks during commit. But the problem would be the same with any one way clean filter.

First the setup: https://github.com/kynan/nbstripout#manual-filter-installation

================================================= Set up a git filter using nbstripout as follows:

git config filter.nbstripout.clean '/path/to/nbstripout' git config filter.nbstripout.smudge cat git config filter.nbstripout.required true

Create a file .gitattributes or .git/info/attributes with:
*.ipynb filter=nbstripout
Apply the filter for git diff of *.ipynb files:
git config diff.ipynb.textconv '/path/to/nbstripout -t'
In file .gitattributes or .git/info/attributes add:
*.ipynb diff=ipynb
=================================================
The problem is that it can't be enforced.

When it's not enforced, we end up with some devs using it and others don't, or more often is the same dev sometimes doesn't have it configured.

When a person has a stripped out notebook checked out, when another person commits un-stripped out notebook, it leads to: invalid `git status` reports, `git pull` breaks, `git stash` doesn't work, since it tries to stash using the filters, and `git pull' can never succeed because it thinks that it'll overwrite the local changes, but `git diff` returns no changes.

So the only solution when this happens is to disable the filters, clean up the mess, re-enable the filters. Many people just make a new clone - ouch!

And the biggest problem is that it affects all users who may have the filters enabled, e.g. because they worked on a PR, and not just devs - i.e. the repercussions are much bigger than just a few devs affected.

We can't use server-side hooks to enforce this because the project is on github.

And the devs honestly try to do their best to remember to configure the filters, but for some reason they disappear for them, don't ask me why, I don't know. This is an open source project team, not a work place.

You can see some related complaints here: https://github.com/kynan/nbstripout/issues/65#issuecomment-430346894 https://stackoverflow.com/questions/51883227/git-pull-stash-conflicts-with-a-git-filter and I can find you a whole bunch more if you need more evidence.

==================================================
Proposed solution:

There needs to be a way for a project to define content filters w/o going via user's .gitconfig configuration, since due to git's security it can't be distributed to all users and must be enabled manually by each user, which is just not the right solution in this case.

Of course, I'm open to other suggestions that may help this issue.

"Tell your developers they must configure the filters" is not it - I tried it for a long time and in vain. If you look at our install instructions: https://github.com/fastai/fastai#developer-install

  git clone https://github.com/fastai/fastai
  cd fastai
  tools/run-after-git-clone

It already includes an instruction to run a script which enables the filters, but this doesn't seem to help (and no, it's not a problem with the script). The devs report that the configuration is there for a while, and then suddenly it is not there, I don't know why. Perhaps they make a new clone and forget to re-enable the filters, perhaps they disable them to clean up and forget to reenable them, I can't tell.

The bottom line it sucks and I hope that you can help with offering a programmatic solution, rather than recommending creating a police department.

Thank you for listening.
-- 
________________________________________________
Stas Bekman       <'))))><       <'))))><
https://stasosphere.com  https://chestofbooks.com
https://experientialsexlab.com https://stason.org
https://stasosphere.com/experience-life/my-books
Next: Ævar Arnfjörð Bjarmason
Message 1 of 7 in “problem with not being able to enforce git content filters”
  1. Stas BekmanOct 16, 2018
  2. Ævar Arnfjörð BjarmasonOct 16, 2018
  3. Stas BekmanOct 16, 2018
  4. brian m. carlsonOct 16, 2018
  5. Stas BekmanOct 16, 2018
  6. brian m. carlsonOct 17, 2018
  7. Stas BekmanOct 17, 2018

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.