Code Monkey home page Code Monkey logo

git-keyword-substitution's Introduction

introduction
============

"keywords" is a git filter which replaces certain keywords on checkout,
resp. restores the keywords on commit.


prerequisites
=============

at least git version v1.7.3.4-599-ga2b665d is needed for this filter.


installation
============

$ vi <PROJECT>/.gitattributes 
---<snip>---
*.c filter=keywords
---<snap>---

$ mkdir <PROJECT>/.git_filters/keywords
$ cp keywords <PROJECT>/.git_filters/keywords

to enable keyword substitution:
$ git config --local filter.keywords.clean ".git_filters/keywords -m clean -f %f"
$ git config --local filter.keywords.smudge ".git_filters/keywords -m smudge -f %f"

to disable keyword substitution:
$ git config --local filter.keywords.smudge "cat"


usage
=====

any occurence of a keyword will be replaced by its value except for lines matching
the following regular expression: /SkIp/

for example the text

---<snip>---
Author:     <AUTHORNAME>
Email:      <AUTHOREMAIL>
---<snap>---

will become on checkout

---<snip>---
Author:     Timo Benk
Email:      [email protected]
---<snap>---

for an example look at the header in "keywords".

to update all keywords on checkout, just checkout the current
HEAD explicitly.

$ cd <PROJECT>
$ git checkout HEAD .


available keywords
==================

lines matching /SkIp/ will not be touched.

<FILE>                       : the filename                                        
<BRANCH>                     : the branch name
<COMMITHASH>                 : commit hash                                         
<COMMITHASHABBREVIATED>      : abbreviated commit hash                             
<TREEHASH>                   : tree hash                                           
<TREEHASHABBREVIATED>        : abbreviated tree hash                               
<PARENTHASHES>               : parent hashes                                       
<PARENTHASHESABBREVIATED>    : abbreviated parent hashes                           
<AUTHORNAME>                 : author name                                         
<AUTHORNAMEMAILCAP>          : author name (respecting .mailmap)                   
<AUTHOREMAIL>                : author email                                        
<AUTHOREMAILMAILCAP>         : author email (respecting .mailmap)                  
<AUTHORDATE>                 : author date (format respects --date= option)        
<AUTHORDATERFC2822>          : author date, RFC2822 style                          
<AUTHORDATERELATIVE>         : author date, relative                               
<AUTHORDATEUNIX>             : author date, UNIX timestamp                         
<AUTHORDATEISO8601>          : author date, ISO 8601 format                        
<COMMITTERNAME>              : committer name                                      
<COMMITTERNAMEMAILCAP>       : committer name (respecting .mailmap)                
<COMMITTERDATE>              : committer date                                      
<COMMITTERDATERFC2822>       : committer date, RFC2822 style                       
<COMMITTERDATERELATIVE>      : committer date, relative                            
<COMMITTERDATEUNIX>          : committer date, UNIX timestamp                      
<COMMITTERDATEISO8601>       : committer date, ISO 8601 format                     
<REFNAMES>                   : ref names, like the --decorate option of git-log(1) 
<ENCODING>                   : encoding                                            
<SUBJECT>                    : subject                                             
<SUBJECTSANITIZED>           : sanitized subject line, suitable for a filename     
<REFLOGSELECTOR>             : reflog selector, e.g., refs/stash@{1}               
<REFLOGSELECTORSHORT>        : shortened reflog selector, e.g., stash@{1}          
<REFLOGIDENTITYNAME>         : reflog identity name                                
<REFLOGIDENTITYNAMEMAILCAP>  : reflog identity name (respecting .mailmap)          
<REFLOGIDENTITYEMAIL>        : reflog identity email                               
<REFLOGIDENTITYEMAILMAILCAP> : reflog identity email (respecting .mailmap)         
<REFLOGSUBJECTS>             : reflog subject                                      

<CHANGELOG:$args:$max:$format> : the git history of this file
- $args   - additional arguments supplied to "git log"               
- $max    - maximum number of log entries to show (-1 == all entries)
- $format - format of the log message (man git-log / --pretty)
- all characters prefixing <CHANGELOG:$args:$max:$format> will be repeated 
  on each line

git-keyword-substitution's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.