forked from freesurfer/freesurfer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rf: testing two methods of RCS keyword expansion
- Loading branch information
Showing
9 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/perl -p | ||
# | ||
# @brief Git filter to implement rcs keyword expansion as seen in cvs and svn. | ||
# @author Martin Turon | ||
# | ||
# Copyright (c) 2009-2011 Turon Technologies, Inc. All rights reserved. | ||
|
||
s/\$Id[^\$]*\$/\$Id\$/; | ||
s/\$Date[^\$]*\$/\$Date\$/; | ||
s/\$Author[^\$]*\$/\$Author\$/; | ||
s/\$Source[^\$]*\$/\$Source\$/; | ||
s/\$File[^\$]*\$/\$File\$/; | ||
s/\$Revision[^\$]*\$/\$Revision\$/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/perl | ||
# | ||
# @brief Git filter to implement rcs keyword expansion as seen in cvs and svn. | ||
# @author Martin Turon | ||
# | ||
# Usage: | ||
# .git_filter/rcs-keywords.smudge file_path < file_contents | ||
# | ||
# To add keyword expansion: | ||
# <project>/.gitattributes - *.c filter=rcs-keywords | ||
# <project>/.git_filters/rcs-keywords.smudge - copy this file to project | ||
# <project>/.git_filters/rcs-keywords.clean - copy companion to project | ||
# ~/.gitconfig - add [filter] lines below | ||
# | ||
# [filter "rcs-keywords"] | ||
# clean = .git_filters/rcs-keywords.clean | ||
# smudge = .git_filters/rcs-keywords.smudge %f | ||
# | ||
# Copyright (c) 2009-2011 Turon Technologies, Inc. All rights reserved. | ||
|
||
$path = shift; | ||
$path =~ /.*\/(.*)/; | ||
$filename = $1; | ||
|
||
if (0 == length($filename)) { | ||
$filename = $path; | ||
} | ||
|
||
# Need to grab filename and to use git log for this to be accurate. | ||
$rev = `git log -- $path | head -n 3`; | ||
$rev =~ /^Author:\s*(.*)\s*$/m; | ||
$author = $1; | ||
$author =~ /\s*(.*)\s*<.*/; | ||
$name = $1; | ||
$rev =~ /^Date:\s*(.*)\s*$/m; | ||
$date = $1; | ||
$rev =~ /^commit (.*)$/m; | ||
$ident = $1; | ||
|
||
while (<STDIN>) { | ||
s/\$Date[^\$]*\$/\$Date: $date \$/; | ||
s/\$Author[^\$]*\$/\$Author: $author \$/; | ||
s/\$Id[^\$]*\$/\$Id: $filename | $date | $name \$/; | ||
s/\$File[^\$]*\$/\$File: $filename \$/; | ||
s/\$Source[^\$]*\$/\$Source: $path \$/; | ||
s/\$Revision[^\$]*\$/\$Revision: $ident \$/; | ||
} continue { | ||
print or die "-p destination: $!\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# .gitattributes | ||
# Map file extensions to git filters | ||
|
||
*.h filter=rcs-keywords | ||
*.c filter=rcs-keywords | ||
*.cc filter=rcs-keywords | ||
*.m filter=rcs-keywords | ||
*.mm filter=rcs-keywords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
[alias] | ||
co = checkout | ||
ci = commit -a | ||
|
||
# To add keyword expansion: | ||
# git init | ||
# cp ~/.gitconfig, <project>/.gitattributes, and <project>/.git_filters | ||
[filter "rcs-keywords"] | ||
clean = .git_filters/rcs-keywords.clean | ||
smudge = .git_filters/rcs-keywords.smudge %f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
This module provides a means to add keyword expansion of the following | ||
standard RCS tags to your git projects: | ||
|
||
$Id$ | ||
$Date$ | ||
$File$ | ||
$Author$ | ||
$Revision$ | ||
$Source$ | ||
|
||
The mechanism used are filters. The smudge filter is run on checkout, and the | ||
clean filter is run on commit. The tags are only expanded on the local disk, | ||
not in the repository itself. | ||
|
||
To start, you need to add the following to ~/.gitconfig: | ||
|
||
[filter "rcs-keywords"] | ||
clean = .git_filters/rcs-keywords.clean | ||
smudge = .git_filters/rcs-keywords.smudge %f | ||
|
||
Then, to add keyword expansion, simply add these files to your project: | ||
<project>/.gitattributes - *.c filter=rcs-keywords | ||
<project>/.git_filters/rcs-keywords.smudge - copy this file to project | ||
<project>/.git_filters/rcs-keywords.clean - copy companion to project | ||
|
||
Note: This feature is known not to work in git 1.6.2.2 and 1.7.3.*, and | ||
verified to work in git 1.7.4.4 and 1.7.4.msysgit.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @file hello.c | ||
* @author @$Author$ | ||
* @date @$Date$ | ||
* @version @$Revision$ | ||
* | ||
* $Id$ | ||
*/ | ||
|
||
#include "stdio.h" | ||
|
||
int main(int argc, char *argv[]) | ||
printf("Hello, world!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
# see man gitattributes | ||
|
||
# Map file extensions to git filters | ||
# See .git-keywords directory and .gitconfig | ||
|
||
*.h filter=kw | ||
*.hpp filter=kw | ||
*.c filter=kw | ||
*.cpp filter=kw | ||
*.py filter=kw | ||
*.am filter=kw | ||
*.m filter=kw | ||
# See .git-keywords directory for kw filter, and .gitconfig | ||
#*.h filter=kw | ||
#*.hpp filter=kw | ||
#*.c filter=kw | ||
#*.cpp filter=kw | ||
#*.py filter=kw | ||
#*.am filter=kw | ||
#*.m filter=kw | ||
|
||
# See .git-rcs-keywords/.git_filters directory for filters, and .gitconfig | ||
*.h filter=rcs-keywords | ||
*.hpp filter=rcs-keywords | ||
*.c filter=rcs-keywords | ||
*.cpp filter=rcs-keywords | ||
*.py filter=rcs-keywords | ||
*.am filter=rcs-keywords | ||
*.m filter=rcs-keywords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
# See .git-keywords directory for README | ||
[filter "kw"] | ||
clean = .git-keywords/kwclean | ||
smudge = .git-keywords/kwset | ||
#[filter "kw"] | ||
# clean = .git-keywords/kwclean | ||
# smudge = .git-keywords/kwset | ||
|
||
# See .git-rcs-keywords for README | ||
[filter "rcs-keywords"] | ||
clean = .git-rcs-keywords/.git_filters/rcs-keywords.clean | ||
smudge = .git-rcs-keywords/.git_filters/rcs-keywords.smudge %f | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters