{"thread":{"id":"52526","subject":"git filters don't get applied to dotfiles","startedAt":"2019-12-27T07:57:02Z","lastAt":"2019-12-30T14:43:14Z","messageCount":3,"participants":["Adrien LEMAIRE","Dennis Kaarsemaker"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"388964","messageId":"CALqn52MbeiCrEzphMkcjeU6bPbLLaQOa-vzht2156uqVw1wL_g@mail.gmail.com","threadId":"52526","inReplyTo":null,"subject":"git filters don't get applied to dotfiles","fromName":"Adrien LEMAIRE","fromEmail":"lemaire.adrien@gmail.com","sentAt":"2019-12-27T07:51:04Z","receivedAt":"2019-12-27T07:57:02Z","isPatch":false,"sender":{"key":"lemaire.adrien@gmail.com","avatar":null},"body":"I'd like to report a bug regarding git filters not being applied to\nfiles beginning with a dot character \".\"\nUsing git version 2.24.1\nPlease let me know if there is a better way to report bugs. The github\npage only mentions this email.\n\nTo give a bit of context, I've followed this arch linux suggestion to\ntrack my dotfiles using the \"bare repository and alias method\".\n\n.gitattributes\n> mailrc filter=remove-smtp-pass\n> .mailrc filter=remove-smtp-pass\n\n\n.dotfiles/config\n> [core]\n> repositoryformatversion = 0\n> filemode = true\n> bare = true\n>\n> [status]\n> showUntrackedFiles = no\n>\n> [filter \"remove-smtp-pass\"]\n> clean = \"sed -e 's/gmail.com:.*@smtp/gmail.com:PASSWORD@smtp/'\"\n\n\nThe file I'm trying to commit is called .mailrc, but to confirm the\nbug, I copied it as mailrc (without leading dot). When adding both\nfiles, the filter only gets applied to the file without leading dot.\n\n> $ config diff --cached\n> diff --git a/.mailrc b/.mailrc\n> new file mode 100644\n> index 0000000..7ac2abb\n> --- /dev/null\n> +++ b/.mailrc\n> @@ -0,0 +1,4 @@\n> +account gmail {\n> +  set v15-compat\n> +  set mta=smtp://lemaire.adrien%40gmail.com:IamApassword@smtp.gmail.com:587 smtp-use-starttls\n> +}\n> diff --git a/mailrc b/mailrc\n> new file mode 100644\n> index 0000000..2698128\n> --- /dev/null\n> +++ b/mailrc\n> @@ -0,0 +1,4 @@\n> +account gmail {\n> +  set v15-compat\n> +  set mta=smtp://lemaire.adrien%40gmail.com:PASSWORD@smtp.gmail.com:587 smtp-use-starttls\n> +}\n> $ config check-attr -a -- mailrc\n> mailrc: filter: remove-smtp-pass\n> $ config check-attr -a -- .mailrc\n> .mailrc: filter: remove-smtp-pass\n\n\nAs reported by check-attr, the .mailrc file is correctly assigned to\nthe filter, but the diff output shows the password.\n\nCordially\nAdrien\n"},{"id":"389035","messageId":"ea322b4c06dce0332ead3521e45514d10f2a76b8.camel@kaarsemaker.net","threadId":"52526","inReplyTo":"CALqn52MbeiCrEzphMkcjeU6bPbLLaQOa-vzht2156uqVw1wL_g@mail.gmail.com","subject":"Re: git filters don't get applied to dotfiles","fromName":"Dennis Kaarsemaker","fromEmail":"dennis@kaarsemaker.net","sentAt":"2019-12-29T16:01:58Z","receivedAt":"2019-12-29T16:05:27Z","isPatch":false,"sender":{"key":"dennis@kaarsemaker.net","avatar":"https://avatars.githubusercontent.com/u/200649?v=4"},"body":"On Fri, 2019-12-27 at 16:51 +0900, Adrien LEMAIRE wrote:\n> I'd like to report a bug regarding git filters not being applied to\n> files beginning with a dot character \".\"\n> Using git version 2.24.1\n> Please let me know if there is a better way to report bugs. The github\n> page only mentions this email.\n\n<snip reproduction recipe>\n\nI was not able to reproduce this in the git test suite with a quick\npatch (see below). Your output does not show any git add command, is it\npossible that you added the changes before configuring the filter?\n\nIf you set GIT_TRACE=2 in your environment before doing the git add of\nthe .mailrc file, you should see it run the filter command. It should\nlook something like:\n\n+ git add test test.t test.i .mailrc\ntrace: built-in: git add test test.t test.i .mailrc\ntrace: run_command: ./rot13.sh\ntrace: run_command: ./rot13.sh\n\n(which is a part of the output of GIT_TRACE=2 ./t0021-conversion.sh -x\n-v -i)\n\n\ndiff --git t/t0021-conversion.sh t/t0021-conversion.sh\nindex 6c6d77b51a..32c27d513b 100755\n--- t/t0021-conversion.sh\n+++ t/t0021-conversion.sh\n@@ -77,6 +77,7 @@ test_expect_success setup '\n \n        {\n            echo \"*.t filter=rot13\"\n+           echo \".mailrc filter=rot13\"\n            echo \"*.i ident\"\n        } >.gitattributes &&\n \n@@ -88,9 +89,10 @@ test_expect_success setup '\n        cat test >test.t &&\n        cat test >test.o &&\n        cat test >test.i &&\n-       git add test test.t test.i &&\n+       cat test >.mailrc &&\n+       git add test test.t test.i .mailrc &&\n        rm -f test test.t test.i &&\n-       git checkout -- test test.t test.i &&\n+       git checkout -- test test.t test.i .mailrc &&\n \n        echo \"content-test2\" >test2.o &&\n        echo \"content-test3 - filename with special characters\" >\"test3 '\\''sq'\\'',\\$x=.o\"\n@@ -102,6 +104,7 @@ test_expect_success check '\n \n        test_cmp test.o test &&\n        test_cmp test.o test.t &&\n+       test_cmp test.o .mailrc &&\n \n        # ident should be stripped in the repository\n        git diff --raw --exit-code :test :test.i &&\n@@ -110,9 +113,12 @@ test_expect_success check '\n        test \"z$id\" = \"z$embedded\" &&\n \n        git cat-file blob :test.t >test.r &&\n+       git cat-file blob :.mailrc >.mailrc.r &&\n \n        ./rot13.sh <test.o >test.t &&\n-       test_cmp test.r test.t\n+       ./rot13.sh <test.o >.mailrc &&\n+       test_cmp test.r test.t &&\n+       test_cmp .mailrc.r .mailrc\n '\n \n # If an expanded ident ever gets into the repository, we want to make sure that\n\n"},{"id":"389060","messageId":"CALqn52MwvhTZ-dAfpg+8VSOQdv84uFei07vYRSj5=jiTYtmPxg@mail.gmail.com","threadId":"52526","inReplyTo":"ea322b4c06dce0332ead3521e45514d10f2a76b8.camel@kaarsemaker.net","subject":"Re: git filters don't get applied to dotfiles","fromName":"Adrien LEMAIRE","fromEmail":"lemaire.adrien@gmail.com","sentAt":"2019-12-30T14:42:35Z","receivedAt":"2019-12-30T14:43:14Z","isPatch":false,"sender":{"key":"lemaire.adrien@gmail.com","avatar":null},"body":"Hi Dennis, and thanks for looking into this.\n\nI cannot reproduce this issue anymore, and it works as expected:\n\n$ GIT_TRACE=2 config add .mailrc\n23:31:05.135580 git.c:439               trace: built-in: git add .mailrc\n23:31:05.135902 run-command.c:663       trace: run_command: 'sed -e\n'\\''s/gmail.com:.*@smtp/gmail.com:PASSWORD@smtp/'\\'''\n\n$ config diff --cached\ndiff --git a/.mailrc b/.mailrc\nnew file mode 100644\nindex 0000000..2698128\n--- /dev/null\n+++ b/.mailrc\n@@ -0,0 +1,4 @@\n+account gmail {\n+  set v15-compat\n+  set mta=smtp://lemaire.adrien%40gmail.com:PASSWORD@smtp.gmail.com:587\nsmtp-use-starttls\n+}\n\nTo answer your question, yes I first added the file without a filter.\nBut I'm pretty sure I did a `config restore --staged .mailrc` after\ncreating the filter (and I actually repeated the operation several\ntimes before contacting you the other day), but I must have been wrong\nabout that.\nI didn't know about the GIT_TRACE environment variable. Thank you for\nteaching me something, and sorry about the false bug report.\n\nBest regards\nAdrien\n\nOn Mon, Dec 30, 2019 at 1:02 AM Dennis Kaarsemaker\n<dennis@kaarsemaker.net> wrote:\n>\n> On Fri, 2019-12-27 at 16:51 +0900, Adrien LEMAIRE wrote:\n> > I'd like to report a bug regarding git filters not being applied to\n> > files beginning with a dot character \".\"\n> > Using git version 2.24.1\n> > Please let me know if there is a better way to report bugs. The github\n> > page only mentions this email.\n>\n> <snip reproduction recipe>\n>\n> I was not able to reproduce this in the git test suite with a quick\n> patch (see below). Your output does not show any git add command, is it\n> possible that you added the changes before configuring the filter?\n>\n> If you set GIT_TRACE=2 in your environment before doing the git add of\n> the .mailrc file, you should see it run the filter command. It should\n> look something like:\n>\n> + git add test test.t test.i .mailrc\n> trace: built-in: git add test test.t test.i .mailrc\n> trace: run_command: ./rot13.sh\n> trace: run_command: ./rot13.sh\n>\n> (which is a part of the output of GIT_TRACE=2 ./t0021-conversion.sh -x\n> -v -i)\n>\n>\n> diff --git t/t0021-conversion.sh t/t0021-conversion.sh\n> index 6c6d77b51a..32c27d513b 100755\n> --- t/t0021-conversion.sh\n> +++ t/t0021-conversion.sh\n> @@ -77,6 +77,7 @@ test_expect_success setup '\n>\n>         {\n>             echo \"*.t filter=rot13\"\n> +           echo \".mailrc filter=rot13\"\n>             echo \"*.i ident\"\n>         } >.gitattributes &&\n>\n> @@ -88,9 +89,10 @@ test_expect_success setup '\n>         cat test >test.t &&\n>         cat test >test.o &&\n>         cat test >test.i &&\n> -       git add test test.t test.i &&\n> +       cat test >.mailrc &&\n> +       git add test test.t test.i .mailrc &&\n>         rm -f test test.t test.i &&\n> -       git checkout -- test test.t test.i &&\n> +       git checkout -- test test.t test.i .mailrc &&\n>\n>         echo \"content-test2\" >test2.o &&\n>         echo \"content-test3 - filename with special characters\" >\"test3 '\\''sq'\\'',\\$x=.o\"\n> @@ -102,6 +104,7 @@ test_expect_success check '\n>\n>         test_cmp test.o test &&\n>         test_cmp test.o test.t &&\n> +       test_cmp test.o .mailrc &&\n>\n>         # ident should be stripped in the repository\n>         git diff --raw --exit-code :test :test.i &&\n> @@ -110,9 +113,12 @@ test_expect_success check '\n>         test \"z$id\" = \"z$embedded\" &&\n>\n>         git cat-file blob :test.t >test.r &&\n> +       git cat-file blob :.mailrc >.mailrc.r &&\n>\n>         ./rot13.sh <test.o >test.t &&\n> -       test_cmp test.r test.t\n> +       ./rot13.sh <test.o >.mailrc &&\n> +       test_cmp test.r test.t &&\n> +       test_cmp .mailrc.r .mailrc\n>  '\n>\n>  # If an expanded ident ever gets into the repository, we want to make sure that\n>\n"}]}