{"thread":{"id":"51343","subject":". components in paths (gitattributes and git hash-object --path)","startedAt":"2019-06-19T21:13:12Z","lastAt":"2019-06-19T21:13:12Z","messageCount":1,"participants":["Oliver Soong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"377582","messageId":"CAPQ=hV+FmdqDBguU6pkevhRQeS3rEyA4HwmVjS-+5VSFTr_CrQ@mail.gmail.com","threadId":"51343","inReplyTo":null,"subject":". components in paths (gitattributes and git hash-object --path)","fromName":"Oliver Soong","fromEmail":"osoong@gmail.com","sentAt":"2019-06-19T21:12:58Z","receivedAt":"2019-06-19T21:13:12Z","isPatch":false,"sender":{"key":"osoong@gmail.com","avatar":null},"body":"First of all, the man page for git hash-object doesn't specify whether\n--path should be relative to the root of the tree or relative to the\ncurrent directory after git -C.  Current behavior seems to be the\nlatter, which is sensible enough and usually works.  While ..\ncomponents seem to be handled correctly, . components seem to get\nmatched literally in both gitattributes patterns and git hash-object\n--path arguments.  On a related note, the man page for git hash-object\ndoesn't specify how a leading --path argument with a leading ./ should\nbe treated.  Given current behavior, I think a leading ./ should\nindicate the current directory.\n\nI can try to work up a patch, but I'd like some confirmation that this\nis not actually intended behavior.\n\nCheers,\nOliver\n\n\n\n#!/bin/sh\n\ngit init --quiet git-bug-test\ncd git-bug-test\ngit config filter.line1.clean 'sed -e 1cclean'\ngit config filter.line1.smudge 'sed -e 1cdirty'\nmkdir sub\ncd sub\nprintf '# prefix\\n'\ngit rev-parse --show-prefix\n\nprintf '# reference dirty object\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin\nprintf '# reference clean object\\n'\nprintf 'clean\\n' | git hash-object -w --stdin\n\nprintf 'sub/* filter=line1\\n' > ../.gitattributes\nprintf '# case 1: sub/* filter; --path=file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=file\nprintf '# case 2: sub/* filter; --path=./file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=./file\nprintf '# case 3: sub/* filter; --path=sub/file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=sub/file\nprintf '# case 4: sub/* filter; --path=./sub/file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=./sub/file\nprintf '# case 5: sub/* filter; --path=../sub/file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=../sub/file\nprintf '# case 6: sub/* filter; --path=../sub/./file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=../sub/./file\n\nprintf 'sub/./* filter=line1\\n' > ../.gitattributes\nprintf '# case 7: sub/./* filter; --path=file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=file\nprintf '# case 8: sub/./* filter; --path=./file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=./file\nprintf '# case 9: sub/./* filter; --path=sub/file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=sub/file\nprintf '# case 10: sub/./* filter; --path=./sub/file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=./sub/file\nprintf '# case 11: sub/./* filter; --path=../sub/file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=../sub/file\nprintf '# case 12: sub/./* filter; --path=../sub/./file\\n'\nprintf 'dirty\\n' | git hash-object -w --stdin --path=../sub/./file\n\n# EOF\n\n\n\nObserved output:\n\n$ git --version\ngit version 2.22.GIT\n$ ./git-bug-test.sh\n# prefix\nsub/\n# reference dirty object\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# reference clean object\n83126302079c10762b29692dc322e430472a5360\n# case 1: sub/* filter; --path=file\n83126302079c10762b29692dc322e430472a5360\n# case 2: sub/* filter; --path=./file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 3: sub/* filter; --path=sub/file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 4: sub/* filter; --path=./sub/file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 5: sub/* filter; --path=../sub/file\n83126302079c10762b29692dc322e430472a5360\n# case 6: sub/* filter; --path=../sub/./file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 7: sub/./* filter; --path=file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 8: sub/./* filter; --path=./file\n83126302079c10762b29692dc322e430472a5360\n# case 9: sub/./* filter; --path=sub/file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 10: sub/./* filter; --path=./sub/file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 11: sub/./* filter; --path=../sub/file\n6e5aa7ceca195942768e6e0997c3a0271b07fffc\n# case 12: sub/./* filter; --path=../sub/./file\n83126302079c10762b29692dc322e430472a5360\n"}]}