I setup the following filters from the Git Attributes documentation:
git config filter.dater.smudge expand_date
git config filter.dater.clean 'perl -pe s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'
Now I run the following commands:
touch nfile.txt
git add --all
And get the following error:
error: copy-fd: read returned Bad file descriptor
error: cannot feed the input to external filter perl -pe "s/\\\$DATE[^\\\$]*\\\$/\\\$DATE\\\$/"
error: external filter perl -pe "s/\\\$DATE[^\\\$]*\\\$/\\\$DATE\\\$/" failed
The error does not appear to be related to my script because if I run this I get no errors:
cat nfile.txt | perl -pe "s/\\\$DATE[^\\\$]*\\\$/\\\$DATE\\\$/"
Further, this old thread mentions that the error could possibly be due to "copy_fd in code called from apply_filter" and recommended to patch the function filter_buffer_or_fd
in th git core file convert
.c. Personally, if I could avoid patching core Git code I would be very happy.
I need to clean up the error messages because I do not want users to see this ugly sort of output during the staging phase of their commits. Is there a way to avoid this? or correct way of handling this situation?
If this has been answered before, I apologize. I could not find an equivalent article on exchange or the internet.