GitWCRev is Windows console program which can be used to read the status of a Git working tree or specific files inside a working tree and optionally perform keyword substitution in a template file - another alternative could be git filters (cf. gitattributes(5) man-page). This is often used as part of the build process as a means of incorporating working tree information into the object you are building. Typically it might be used to include the revision number in an “About” box.
GitWCRev reads the Git status of all files in a working tree OR a directory/file inside a working tree including submodules. It records the HEAD commit revision and the commit timestamp, it also records whether there are local modifications in the passed path. The status revision and modification status are displayed on stdout.
GitWCRev.exe is called from the command line or a script, and is controlled using the command line parameters.
GitWCRev WorkingTreePath [SrcVersionFile DstVersionFile] [-mMuUsdq]
WorkingTreePath is the path to the working tree OR a directory/file inside a working tree to check. The path may be absolute or relative to the current working directory.
If you want GitWCRev to perform keyword substitution, so that fields like repository revision is saved to a text file, you need to supply a template file
SrcVersionFile and an output file
DstVersionFile which contains the substituted version of the template.
You can specify ignore patterns for GitWCRev to prevent specific files and paths from being considered. The patterns are read from a file named
.gitwcrevignore. The file is read from the working tree root. If the file does not exist, no files or paths are ignored. The
.gitwcrevignore file can contain multiple patterns, separated by newlines. The patterns are matched against the paths relative to the repository root . For example, to ignore all files in the
/doc folder of the TortoiseGit working tree, the
.gitwcrevignore would contain the following lines:
To ignore all images, the ignore patterns could be set like this:
*.png *.jpg *.ico *.bmp
The ignore patterns are case-sensitive, just like Git is.
To create a file with a starting dot in the Windows explorer, enter
.gitwcrevignore.. Note the trailing dot.
There are a number of optional switches which affect the way GitWCRev works. If you use more than one, they must be specified as a single group, e.g.
Table 3.1. List of available command line switches
|-m||If this switch is given, GitWCRev will exit with |
|-M||Same as above, but includes the status of submodules.|
|-u||If this switch is given, GitWCRev will exit with |
|-U||Same as above, but includes the status of submodules.|
|-d||If this switch is given, GitWCRev will exit with |
|-s||If this switch is given, GitWCRev will exclude submodules. The default behavior is to also check submodules.|
|-F||If this switch is given, GitWCRev will ignore any |
|-q||If this switch is given, GitWCRev will perform the keyword substitution without showing working tree status on stdout.|
If there is no error, GitWCRev returns zero. But in case an error occurs, the error message is written to stderr and shown in the console. And the returned error codes are:
Table 3.2. List of GitWCRev error codes
|1||Syntax error. One or more command line parameters are invalid.|
|2||The file or folder specified on the command line was not found.|
|3||The input file could not be opened, or the target file could not be created.|
|4||Could not allocate memory. This could happen if e.g. the source file is too big.|
|5||The source file can not be scanned properly.|
|6||Git error: libgit2 returned with an error when GitWCRev tried to find the information from the working tree.|
|7||The working tree has local modifications. This requires the |
|9||The output file already exists. This requires the |
|10||The specified path is neither a working tree, a bare repository nor part of one.|
|11||The passed path has unversioned files or folders in it. This requires the |