TheLocehiliosan / yadm

Yet Another Dotfiles Manager

Home Page:https://yadm.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yadm not applying git filter

stefan-muc opened this issue · comments

Motivation: Git does indent .gitconfig with tabs (see StackOverflow), but I have that mixed in my config. I want to make sure that I only commit tabs - which could be done elegantly using a git filter.

But as far as I figured out:

Describe the bug

yadm doesn't seem to apply git filter during staging of a changed file

To reproduce

Steps to reproduce the behavior:

  • Have a running yadm with an already commited .gitignore (filename doesn't matter, but example has to be changed then)
  • Change something in this .gitignore to make file dirty

Set up a test filter:

yadm config filter.test.clean "echo 'the filter has been applied'"
echo ".gitconfig filter=test" > $(yadm rev-parse --git-path info/attributes)

You can confirm that configuration is set up correctly reading it:

user@server:~$ yadm config filter.test.clean
echo 'the filter has been applied'
user@server:~$ yadm check-attr filter .gitconfig
.gitconfig: filter: test

But staging a change in the file doesn't apply the filter:

user@server:~$ echo 'test' > .gitconfig
user@server:~$ yadm add -p .gitconfig
[... normal diff get's displayed, no filter applied]

If you re-do the whole setup but use git instead of yadm, it works as expected:

user@server:~/tmp$ git add -p .gitconfig
diff --git a/.gitconfig b/.gitconfig
index 33194a0..e968616 100644
--- a/.gitconfig
+++ b/.gitconfig
@@ -1 +1 @@
-old content
+the filter has been applied
(1/1) Stage this hunk [y,n,q,a,d,e,?]?

I would expect yadm to apply the filter just as git with same config does. How can I achieve this?
Documentation didn't tell me why this shouldn't work.

Can this be reproduced with the yadm/testbed docker image: [not tested]

Environment

Tested on Debian 12.2 using git version 2.39.2, yadm version 3.2.2

@stefan-muc Can you retry using yadm gitconfig instead of yadm config, per https://github.com/TheLocehiliosan/yadm/blob/master/yadm.md#commands ?

I know this isn't intuitive. It would be preferable that, if yadm config is passed a setting that doesn't apply to yadm, that yadm simply passes it onto git. Unfortunately, that doesn't seem to be the case.

#251 may provide you some ideas on how to work around this issue.

@stefan-muc Can you retry using yadm gitconfig instead of yadm config

Oh great, this works! Thank you very much for your support!