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

Re: What's cooking in git.git (Jun 2010, #04; Wed, 23)

From
Finn Arne Gangstad <finnag@pvv.org>
Date
Jun 25, 2010, 07:46 UTC
Message-ID
<20100625074623.GA4734@pvv.org>
In-Reply-To
<7veifwchb6.fsf@alter.siamese.dyndns.org>
On Thu, Jun 24, 2010 at 01:21:49PM -0700, Junio C Hamano wrote:
Show 6 quoted lines
> >
> > If .gitattributes is different on the different sides, or if you
> > enable autocrlf, the current repo contents may change after
> > git-to-worktree and worktree-to-git again.
> 
> IOW, g2w-then-w2g may not be an identity function.

Absolutely, pretty much by definition this cannot be the case (and is not the case for any of the built-in filters like eol, autocrlf, ident), since you have no control of what you have in the repository before you enable the filter.

What we assume though is that g2w(g2w(x)) == g2w(x). I think it is very hard to come up with a reasonable case for a filter where that is not the case.

> If we were to encourage use of this codepath to wider audiences, we may
> need to have a document for people who write smudge/clean filters.  In
> order for the result to be stable, applying g2w-then-w2g once again on top
> of the result of running g2w-then-w2g on anything should be no-op, no?

This _has_ to work, otherwise you would get dirty contents after a checkout, and that would be horrible.

So, the follolwing should be true:

g2w(x) == g2w(g2w(x)) A -> g2w() -> B -> g2w() -> B ...

w2g(g2w(x)) == w2g(g2w(w2g(g2w(x)))) X -> g2w() -> w2g() -> Y -> g2w() -> w2g() -> Y ...

Running w2g() twice should also be the same as running it once. I thought nothing in git required it as such, but in the case of a missing smudge filter git will call w2g() on something that is already cleaned. I think the clean/smudge guidelines should be:

  "Both clean and smudge filters should be idempotent; running them
   multiple times should not alter the contents further."
- Finn Arne
Previous: Johannes SixtNext: Johannes Sixt
Message 16 of 24 in “What's cooking in git.git (Jun 2010, #04; Wed, 23)”
  1. Junio C HamanoJun 23, 2010
  2. Ævar Arnfjörð BjarmasonJun 23, 2010
  3. Nazri RamliyJun 24, 2010
  4. Tay Ray ChuanJun 24, 2010
  5. Finn Arne GangstadJun 24, 2010
  6. Johannes SixtJun 24, 2010
  7. Finn Arne GangstadJun 24, 2010
  8. Eyvind BernhardsenJun 24, 2010
  9. Junio C HamanoJun 24, 2010
  10. Eyvind BernhardsenJun 24, 2010
  11. Junio C HamanoJun 24, 2010
  12. Finn Arne GangstadJun 25, 2010
  13. Eyvind BernhardsenJun 25, 2010
  14. Junio C HamanoJun 25, 2010
  15. Johannes SixtJun 25, 2010
  16. Finn Arne GangstadJun 25, 2010
  17. Johannes SixtJun 24, 2010
  18. git log --objectsHolger Hellmuth, Jun 24, 2010
  19. Santi BéjarJun 25, 2010
  20. Clément PoulainJun 24, 2010
  21. Christian CouderJun 25, 2010
  22. Ævar Arnfjörð BjarmasonJun 25, 2010
  23. Michael J GruberJun 25, 2010
  24. Shawn O. PearceJun 23, 2010

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.