I am writing git smudge filter.
.gitconfig
[filter "smudgey"]
smudge = smudge_filter
smudge_filter
#!/usr/bin/env bash
# $Id Date: Wed, Mar 25, 2020 1:41:34 PM, User: Joey Gough, Branch: master$
IFS=
log_string="\$Log\nhello world"
changed_data=$(sed s/\$Log[^$]*/"$log_string"/g $1)
echo $changed_data
filtered file
$Log$
Result
When I check out this file, it converts the Log tag and inserts "hello world"
$Log
hello world$
Situation
When I rewrite the .gitconfig
to this:
[filter "smudgey"]
smudge = smudge_filter --smudge %f
It prints out two newlines and that's all.
I have tried so many different approaches and so far it seems as though I cannot access the filename and the file contents at the same time in a Bash script.
Question
How do I access the file contents and the filename at the same time in the git filter? Or can I?