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

Re: gitattributes - clean filter invoked on pull?

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Apr 11, 2011, 10:00 UTC
Message-ID
<4DA2D14D.6010707@viscovery.net>
In-Reply-To
<20110411093114.GY5146@genesis.frugalware.org>
Am 4/11/2011 11:31, schrieb Miklos Vajna:
Show 17 quoted lines
> On Mon, Apr 11, 2011 at 02:49:21PM +0530, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
>>> Is this a bug? I don't exactly understand why this would be necessary.
>>
>> From config.txt:
>> - 'clean' is "The command which is used to convert the content of a
>> worktree file to a blob upon checkin".
>> - 'smudge' is "The command which is used to convert the content of a
>> blob object to a worktree file upon checkout."
>>
>> According to the documentation, 'smudge' is *supposed* to be invoked
>> on a clone/ pull, since it involves a checkout.  I don't see how you
>> can avoid running these filters on every checkin/ checkout unless you
>> cache the result somewhere.
> 
> That's not a problem - the issue I pointed out is that the 'clean' one
> is invoked on pull/clone, and it takes time if it's applied to several
> files.

The invocation is only needed when files are marked as "racily clean", because in this case git has to check whether the worktree contents are what is recorded in the index or not. This can happen a lot when you have a fast machine where many worktree files and the index itself can be written within the same (wall clock) second. You example is so short that it triggers this case almost reliably.

When git pull merges the fetched commit, it has to determine whether there are no changes in any of the files that are to be updated by the merge. If one such file is marked as racily clean, the worktree contents must be inspected, which in turn means that the clean filter has to be used.

If you insert before the final 'git pull':

sleep 1 git reset sleep 1

you will notice that some clean filter calls happen before the 'git pull' because git 'git reset' rectifies the racily-clean entry.

This just explains what you observed. I haven't thought about how you should change your workflow to avoid this behavior. My guess is that the extra clean filters called by 'git pull' don't actually happen that frequently during normal interactive work that touches the index.

Perhaps you are also bitten by a regression in 'git status', which does not correct the racily-clean entries even though it should (fixed in git 1.7.4.4.), and therefore the clean filter is run more often than necessary.

> 
> 'smudge' is just a 'cat', I don't care about it. :)

Then you can just remove it from the config and save a fork(). You don't have to configure both clean and smudge filters.

-- Hannes
Previous: Ramkumar RamachandraNext: Michael J Gruber
Message 5 of 10 in “gitattributes - clean filter invoked on pull?”
  1. Miklos VajnaApr 11, 2011
  2. Ramkumar RamachandraApr 11, 2011
  3. Miklos VajnaApr 11, 2011
  4. Ramkumar RamachandraApr 11, 2011
  5. Johannes SixtApr 11, 2011
  6. Michael J GruberApr 11, 2011
  7. Miklos VajnaApr 11, 2011
  8. Michael J GruberApr 11, 2011
  9. Miklos VajnaApr 11, 2011
  10. Dmitry PotapovApr 11, 2011

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.