Skip to content

Instantly share code, notes, and snippets.

@treyharris
Last active February 28, 2020 12:26
Show Gist options
  • Save treyharris/f6ced9d61f451cc69f48 to your computer and use it in GitHub Desktop.
Save treyharris/f6ced9d61f451cc69f48 to your computer and use it in GitHub Desktop.
Example of why ident attribute doesn't work in Git like CSV/SVN
#!/bin/zsh
# Make any non-zero return fatal just in case
setopt err_exit
source =(curl https://gist.githubusercontent.com/treyharris/c486c9f8776802e270b7/raw/2d0519826f3b8ca8446f59211ecd0dc738221d3d/showshell.zsh 2> /dev/null)
local dir=/tmp/ident-test
local files=5
show "Setting up ${dir}" "
rm -rf ${dir}
mkdir ${dir}
cd ${dir}
"
show "Setting up git" "
git init
echo '*.txt ident' > .gitattributes
"
for file ({1..${files}}.txt) {
echo '$Id$' > ${file}
git add "${file}"
git commit -m "Adding ${file}"
}
show "Show we do have ${files} commits for each file:" "
git log --stat --oneline --decorate
"
show "Show the current contents" "
cat *.txt
"
show "Git doesn't replace the \$Id\$ token until it must write the file" "
rm *
git reset --hard
cat *.txt
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment