Keyword substitution

CVS supports the substitution of certain keywords in source code. For example, $Author$, $CVSHeader$, and $Id$.Developers have used this feature frequently (some still do). To use this mechanism, you would insert the keyword – let's call it a special variable – in your text or source file. Then, you would commit this file to your repository. By doing this, CVS will substitute this variable with the value in the CVS context during the commit. A lot of people use the $Id$ string in their C source code. You can turn off this behavior completely in CVS by specifying -ko on the command line.

As an example, let's say I add a keyword to a source file, as follows:

{
"name": "cvsproject",
"version": "1.0.0",
"description": "something",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [],
"author": "$Author$",
"license": "ISC"
}

Then, I would commit this change:

$ cvs commit -m "Added author keyword"
cvs commit: Examining .
cvs commit: Examining images
/Users/joostevertse/cvsroot/cvsproject/cvsproject/package.json,v <-- package.json
new revision: 1.3; previous revision: 1.2

After the commit, the keyword has been substituted by my username:

"author": "$Author: joostevertse $",

Git has a very limited set of keywords, and this is because changes are per repository and not per file. Also, Git avoids modifying files that didn't change when switching to another branch or rewinding to another point in time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.227.194