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

Re: [PATCH 2/2] Add keyword unexpansion support to convert.c

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Apr 17, 2007, 15:46 UTC
Message-ID
<Pine.LNX.4.64.0704170833560.5473@woody.linux-foundation.org>
In-Reply-To
<7v7isbpb0p.fsf@assigned-by-dhcp.cox.net>
On Tue, 17 Apr 2007, Junio C Hamano wrote:
Show 7 quoted lines
>
> Andy Parkins <andyparkins@gmail.com> writes:
> 
> > No parsing of the keyword itself is performed, the content is simply
> > dropped.
> 
> You are sidestepping the most important problem by doing this.
I obviosly agree (and I agree with everything in your email), but:
> The only sensible keyword you could have, without destroying
> what git is, is blob id.  No commit id, no date, no author.

Yes. And I already talked about some of the very fundamental problems that keyword expansion has (ie switching branches is basically impossible to do without checking out _every_single_file_ with the "keyword" attribute set. There are others).

Now, unexpansion is trivial to do (it really *is* the same as the "CRLF->LF" translation: that's technically really just an "unexpansion" too). And it should work.

The way this does unexpansion also breaks "git diff" in that it bassically always makes diff *ignore* the keywords. In other words, when you do

	git diff A..B
and send the diff to somebody else, they'll never see any keywords at all! 

Now, that obviously fulfills my requirement that the diff be empty if A and B are the same, so you should expect me to be happy. But I'm not happy, because if the other person also is using git, HE CANNOT EVEN APPLY THE DIFF! Even if he's at "A", and thus gets a diff that is supposed to apply *exactly*, he'll get rejects if there were other changes around the unexpanded keyword (which *he* will have expanded in his working tree, of course!)

See? Keywords simply *cannot* work. They're broken. Either you can ignore them (and not show them in diffs), in which case the diff is broken, or you can not ignore them (and show them in diffs) in which case the diff is *also* broken, just differently.

The only sane and workable case is to not have them at all. Any keyword expansion will *always* result in problems. You simply cannot do it right.

As I mentioned originally, it results in problems in CVS too, it's just that CVS really has so many other issues that you seldom see the problems.

Ok, after that new rant against keywords, I will say one positive thing:
 - keyword *unexpansion* is certainly easy (exactly because it's 
   stateless)
 - if we want to support a git that only does "unexpansion", you can 
   probably hack around stupid release scripting more easily. You can add 
   your keywords *outside* of git, and git will simply ignore them. 

So I'm actually not against keyword un-expansion. It has none of the fundamental problems that actually expanding the keywords has. It's literally no different from CRLF->LF translation. It can cause confusion, but if it has to be explicitly enabled with an attribute and is never done automatically, then having some support for unexpansion and letting the user who wants to use keywords use his own "wrapper scripts" around git to do his own expansion, be my guest..

You would be unable to do fundamental operations like "git checkout B" to jump to another branch, but if you don't support multiple branches and want to just act like CVS, maybe git unexpanding the crap will help you: you can add your own keywords, happy in the knowledge that git simply won't *care* about them, and will never see them.

So I absolutely detest keyword expansion and actually have a lot of arguments for why I don't think it *can* work even in theory (except by being totally unusable), but I don't have the *un*expansion.

		Linus
Previous: David LangNext: Johannes Sixt
Message 44 of 66 in “Add keyword unexpansion support to convert.c”
  1. 2/2 Add keyword unexpansion support to convert.cAndy Parkins, Apr 17, 2007
  2. Junio C HamanoApr 17, 2007
  3. Andy ParkinsApr 17, 2007
  4. Linus TorvaldsApr 17, 2007
  5. Andy ParkinsApr 17, 2007
  6. Linus TorvaldsApr 17, 2007
  7. Andy ParkinsApr 17, 2007
  8. Nicolas PitreApr 17, 2007
  9. David LangApr 17, 2007
  10. Nicolas PitreApr 17, 2007
  11. David LangApr 17, 2007
  12. Nicolas PitreApr 17, 2007
  13. David LangApr 17, 2007
  14. Andy ParkinsApr 17, 2007
  15. Junio C HamanoApr 17, 2007
  16. Nicolas PitreApr 18, 2007
  17. Junio C HamanoApr 18, 2007
  18. Nicolas PitreApr 18, 2007
  19. Johannes SchindelinApr 18, 2007
  20. Nicolas PitreApr 18, 2007
  21. Johannes SchindelinApr 19, 2007
  22. David LangApr 21, 2007
  23. Junio C HamanoApr 21, 2007
  24. Nicolas PitreApr 21, 2007
  25. David LangApr 21, 2007
  26. Rogan DawesApr 18, 2007
  27. Linus TorvaldsApr 18, 2007
  28. Nicolas PitreApr 18, 2007
  29. Rogan DawesApr 18, 2007
  30. Nicolas PitreApr 18, 2007
  31. Rogan DawesApr 18, 2007
  32. Alon ZivApr 18, 2007
  33. Linus TorvaldsApr 17, 2007
  34. Andy ParkinsApr 17, 2007
  35. Add keyword collapse support to convert.cAndy Parkins, Apr 17, 2007
  36. Linus TorvaldsApr 17, 2007
  37. Linus TorvaldsApr 17, 2007
  38. Johannes SchindelinApr 18, 2007
  39. Nikolai WeibullApr 20, 2007
  40. Martin LanghoffApr 17, 2007
  41. Junio C HamanoApr 17, 2007
  42. Jakub NarebskiApr 20, 2007
  43. David LangApr 21, 2007
  44. Linus TorvaldsApr 17, 2007
  45. Johannes SixtApr 17, 2007
  46. Linus TorvaldsApr 17, 2007
  47. Andy ParkinsApr 17, 2007
  48. Rogan DawesApr 17, 2007
  49. Linus TorvaldsApr 17, 2007
  50. Rogan DawesApr 17, 2007
  51. Robin H. JohnsonApr 17, 2007
  52. Junio C HamanoApr 18, 2007
  53. J. Bruce FieldsApr 18, 2007
  54. Linus TorvaldsApr 18, 2007
  55. Junio C HamanoApr 18, 2007
  56. Linus TorvaldsApr 18, 2007
  57. Robin H. JohnsonApr 18, 2007
  58. Junio C HamanoApr 18, 2007
  59. Junio C HamanoApr 18, 2007
  60. Robin H. JohnsonApr 18, 2007
  61. Daniel BarkalowApr 18, 2007
  62. Johannes SchindelinApr 18, 2007
  63. Martin LanghoffApr 18, 2007
  64. David KågedalApr 18, 2007
  65. Robin H. JohnsonApr 18, 2007
  66. Matthieu MoyApr 17, 2007

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.