Skip to content

Conversation

@albfan
Copy link

@albfan albfan commented Dec 6, 2021

I use this as an example to learn from git filters, thanks!

But I notice several flaws, most obvious that clean and smudge are inverted. On clean, USERNAME and PASSWORD should be replaced, and on smudge, they should be restored.

These days update to python3 looks reasonable,

Mention your js option is worth (maybe on a different branch?)

Be able to config custom local config but git config avoids errors

Add command to script shebang and call locally with ./

Let me know if you find these useful, just looking to ease to learn these concepts.

Update to python3
Fix correct filter to smudge and clean
Use subcommands instead of options
Fix correct filter to smudge and clean
Use subcommands instead of options
Include keyfilter.js
Add config to custom keyconfig with git config commands
@albfan
Copy link
Author

albfan commented Dec 6, 2021

This is how that config works on an example repo:

$ cat .gitattributes 
config.json    filter=keyfilter

$ git config --local include.path
../.gitconfig

$ git config --file .gitconfig -l
filter.keyfilter.smudge=./keyfilter.py smudge
filter.keyfilter.clean=./keyfilter.py clean

$ cat config.json 
{
    "user": "USERNAME",
    "pass": "PASSWORD"
}

$ git diff --cached
diff --git c/config.json i/config.json
new file mode 100644
index 0000000..ceda14a
--- /dev/null
+++ i/config.json
@@ -0,0 +1,5 @@
+{
+    "user": "github",
+    "pass": "123456"
+}
+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant