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

Re: Does GIT has vc keywords like CVS/Subversion?

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 9, 2006, 16:13 UTC
Message-ID
<Pine.LNX.4.64.0610090904360.3952@g5.osdl.org>
In-Reply-To
<4529B77A.707@gmail.com>
On Mon, 9 Oct 2006, Liu Yubao wrote:
> 
> IMHO, I don't think keyword substitution is a good idea, as it will confuse
> the external diff/merge tools.

There are other reasons why it's a _horrible_ idea, like the fact that it can mess up binary files etc (so if you do keyword substitution, you also need to suddenly care _deeply_ whether a file is binary or not).

The whole notion of keyword substitution is just totally idiotic. It's trivial to do "outside" of the actual content tracking, if you want to have it when doing release trees as tar-balls etc.

So:
 - inside of the SCM, keyword substitution is pointless, since you have 
   much better tools available (like "git log filename")
 - outside of the SCM, keyword substitution can make sense, but doing it 
   should be in helper scripts or something that can easily tailor it for 
   the actual need of that particular project.

For example, we actually do a certain kind of keyword subtituion for the kernel. Look at the -git snapshots: the script that generates the snapshot diffs has a simple sequence in it to "keyword substitute" the Makefile for the EXTRAVERSION flag, so the diff will result in the Makefile having the knowledge of which git SHA1 version the resulting patch was, even though the thing isn't a git tree any more:

	...
	git-read-tree $CURCOMM
	git-checkout-index Makefile
	perl -pi -e "s/EXTRAVERSION =.*/EXTRAVERSION = $EXTRAVERSION/" Makefile
	git-diff-index -m -p $RELTREE | gzip -9 > $STAGE/patch-$CURNAME.gz
	...
So this is how to do keyword substitution in a _sane_ way.

Sure, we could do something like this as a git script, and support it "natively", but the fact is, keyword substitution is just stupid.

		Linus
Previous: Petr BaudisNext: Martin Langhoff
Message 4 of 12 in “Does GIT has vc keywords like CVS/Subversion?”
  1. Dongsheng SongOct 9, 2006
  2. Liu YubaoOct 9, 2006
  3. Petr BaudisOct 9, 2006
  4. Linus TorvaldsOct 9, 2006
  5. Martin LanghoffOct 9, 2006
  6. Johannes SchindelinOct 9, 2006
  7. Martin LanghoffOct 9, 2006
  8. Junio C HamanoOct 9, 2006
  9. Rene ScharfeOct 10, 2006
  10. Shawn PearceOct 10, 2006
  11. Linus TorvaldsOct 10, 2006
  12. Junio C HamanoOct 10, 2006

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.