Last active
December 12, 2020 19:08
-
-
Save stufield/86483ea41dbbf9a25a9f77b5bfbee42a to your computer and use it in GitHub Desktop.
Git Keyword Expansion like SVN
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
# set up filters | |
git init | |
git config filter.kwd.clean ./filter_clean | |
git config filter.kwd.smudge ./filter_smudge | |
echo "*.txt ident" > .gitattributes | |
echo "*.txt filter=kwd" >> .gitattributes | |
git add -A | |
rm test.txt | |
git checkout test.txt | |
head test.txt | |
# -------------------- | |
# Revision Info | |
# -------------------- | |
# $Id$ | |
# $Author$ | |
# $Date$ | |
################################### | |
# -------------------- | |
# Revision Info | |
# -------------------- | |
# $Id: dac9e60907658dff686543f0efb1e878a2a39c96 $ | |
# $Author: Stu Field $ | |
# $Date: Tue Dec 13 11:22:28 2016 -0700 $ | |
################################### |
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
#!/bin/bash | |
# -------------------------------------------- | |
# This is run when files are staged; putting things | |
# back the way they are in the repository | |
# -------------------------------------------- | |
sed -e "s/[$]Date:.*[$]/\$Date\$/" -e "s/[$]Author:.*[$]/\$Author\$/" |
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
#!/bin/bash | |
# -------------------------------------------- | |
# This is run on a checkout from a branch/repository | |
# it replaces the words "Date" and "Author" with appropriate substitutions | |
# -------------------------------------------- | |
curdate=`git log --pretty=format:"%ad" -1` | |
aut=`git log --pretty=format:"%an" -1` | |
sed -e "s/[$]Date[$]/\$Date: $curdate \$/" -e "s/[$]Author[$]/\$Author: $aut \$/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment