TortoiseGit Manual

Keyword Example

The example below shows how keywords in a template file are substituted in the output file.

// Test file for GitWCRev

char* Revision                    = "$WCREV$";
char* RevisionShort               = "$WCREV=7$";
char* Modified                    = "$WCMODS?Modified:Not modified$";
char* Unversioned                 = "$WCUNVER?Unversioned items found:no unversioned items$";
char* Date                        = "$WCDATE$";
char* DateUTC                     = "$WCDATEUTC$";
char* CustDate                    = "$WCDATE=%a, %d %B %Y$";
char* CustDateEmpty               = "$WCDATE=$";
char* CustDateInval               = "$WCDATE=%a, %c %B %Y$";
char* CustDateUTC                 = "$WCDATEUTC=%a, %d %B %Y$";
char* TimeNow                     = "$WCNOW$";
char* TimeNowUTC                  = "$WCNOWUTC$";
char* IsTagged                    = "$WCISTAGGED?Tagged:Not tagged$";
char* IsInGit                     = "$WCINGIT?versioned:not versioned$";
char* ModifiedFiles               = "$WCFILEMODS?Modified:Not modified$";
char* HasSubmodule                = "$WCSUBMODULE?Working tree has at least one submodule:Working tree has no submodules$";
char* SubmodulesUp2Date           = "$WCSUBMODULEUP2DATE?All submodules are up2date (checked out HEAD):At least one submodule is not up2date (checked HEAD differs)$";
char* SubmoduleHasModifications   = "$WCMODSINSUBMODULE?At least one submodule has uncommitted items:No submodule has uncommitted items$";
char* SubmoduleHasUnversioned     = "$WCUNVERINSUBMODULE?At least one submodule has unversioned files:No submodule with unversioned files$";
char* ModifiedAlsoInSubmodules    = "$WCMODSFULL?Modified items found (recursively):No modified items found (also not in submodules)$";
char* UnversionedAlsoInSubmodules = "$WCUNVERFULL?Unversioned items found (recursively):No unversioned items found (also not in submodules)$";

#if $WCMODSFULL?1:0$
#error Source is modified
#endif

// End of file

After running GitWCRev.exe path\to\workingcopy testfile.tmpl testfile.txt, the output file testfile.txt would looks like this:

// Test file for GitWCRev

char* Revision                    = "c16403bd41ba502935dee309fac137df0807f31e";
char* RevisionShort               = "c16403b";
char* Modified                    = "Modified";
char* Unversioned                 = "Unversioned items found";
char* Date                        = "2017/01/19 15:33:51";
char* DateUTC                     = "2017/01/19 14:33:51";
char* CustDate                    = "Thu, 19 January 2017";
char* CustDateEmpty               = "";
char* CustDateInval               = "Thu, 01/19/17 15:33:51 January 2017";
char* CustDateUTC                 = "Thu, 19 January 2017";
char* TimeNow                     = "2017/01/19 15:35:36";
char* TimeNowUTC                  = "2017/01/19 14:35:36";
char* IsTagged                    = "Not tagged";
char* IsInGit                     = "versioned";
char* ModifiedFiles               = "Not modified";
char* HasSubmodule                = "Working tree has at least one submodule";
char* SubmodulesUp2Date           = "At least one submodule is not up2date (checked HEAD differs)";
char* SubmoduleHasModifications   = "No submodule has uncommitted items";
char* SubmoduleHasUnversioned     = "At least one submodule has unversioned files";
char* ModifiedAlsoInSubmodules    = "Modified items found (recursively)";
char* UnversionedAlsoInSubmodules = "Unversioned items found (recursively)";

#if 1
#error Source is modified
#endif

// End of file

Tip

A file like this will be included in the build so you would expect it to be versioned. Be sure to version the template file, not the generated file, otherwise each time you regenerate the version file you need to commit the change, which in turn means the version file needs to be updated.