I am trying to implement a basic string replacement in the header of my code with git filter clean
feature.
Here is what I did so far:
I created a .gitattributes
:
; Filters for .c, .h files
*.c filter=code_filters
*.h filter=code_filters
Then in my project config
:
[filter "code_filters"]
clean = sed.exe -e "s/Project\s*:.*/Project : My Current Project/"
Since I am on Windows, I use sed from cygwin which is in my path. The regular expression seems correct:
$ echo "Project :" | sed.exe -e "s/Project\s*:.*/Project : My Current Project/"
Project : My Current Project
Unfortunately, the filter syntax is not accepted. For any git command I get:
fatal: bad config file line 14 in .git/config
Could someone tell me what I am doing wrong here?
Note: I left the .exe extension to focus on the Windows aspect of my question. I'll remove it when it will work!
I got it working by escaping the / character so code looks like
[filter "code_filters"]
clean = sed -e 's/Project\\s*:.*/Project : My Current Project/'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.