{"thread":{"id":"57315","subject":"clean/smudge-filter with \"attached file\"?","startedAt":"2022-01-26T13:09:48Z","lastAt":"2022-01-26T20:07:01Z","messageCount":2,"participants":["Josef Wolf","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"446957","messageId":"20220126125209.GD16463@raven.inka.de","threadId":"57315","inReplyTo":null,"subject":"clean/smudge-filter with \"attached file\"?","fromName":"Josef Wolf","fromEmail":"jw@raven.inka.de","sentAt":"2022-01-26T12:52:09Z","receivedAt":"2022-01-26T13:09:48Z","isPatch":false,"sender":{"key":"jw@raven.inka.de","avatar":null},"body":"Hello,\n\nI have an application, which creates XML data files with attached\nchecksum (uuencoded sha1) files. For example, the application might\ncreate\n\n  a/b/c              # XML file\n  a/b/c.chsum        # chsum of this file\n  a/b/d/e            # another XML file\n  a/b/d/e.chsum      # chsum of this file\n\nIt creates hundreds of those files, some with chsum-files attached\nand some not. And some of those files are XML, other are binary or\nsimple text.\n\nIn addition, this application \"shuffles\" content of those XML files,\nwhich results in a lot of clutter when those files are tracked by git.\n\nUnfortunately, the application refuses to load those files when the\nchecksum file does not match its contents.\n\nThose files seemed to be good candidates for git's clean/smudge-filter.\n\nA clean-filter would bring the files into a canonical format (that is,\nsorted and whitespace-normalized) when the file is to be committed.\n\nA smudge-filter would be used to re-calculate the checksum-files on\ncheckout/update.\n\nUnfortunately, the description of clean/smudge-filters states:\n\n   Note that \"%f\" is the name of the path that is being worked on.\n   Depending on the version that is being filtered, the corresponding\n   file on disk may not exist, or may have different contents. So,\n   smudge and clean commands should not try to access the file on disk, but\n   only act as filters on the content provided to them on standard input.\n\nUh! That means that the content the filter emits on stdout does not\nnececcerily match the content that is supposed to be in the file when the\ngit command finishes? Thus, simply calculate the checksum and store it in\nassociated checksum file might result in a checksum failure when the\napplication tries to load those files?\n\nAm I missing something? Or am I completely off the road?\n\nAny help?\n\n-- \nJosef Wolf\njw@raven.inka.de\n"},{"id":"446990","messageId":"xmqqbkzyqn1b.fsf@gitster.g","threadId":"57315","inReplyTo":"20220126125209.GD16463@raven.inka.de","subject":"Re: clean/smudge-filter with \"attached file\"?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-26T20:06:56Z","receivedAt":"2022-01-26T20:07:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josef Wolf <jw@raven.inka.de> writes:\n\n> Those files seemed to be good candidates for git's clean/smudge-filter.\n\nPerhaps post-checkout hook to notice missing checksum files and\nrecompute them would work, but this is clearly outside of what\nclean/smudge wants to do and what they were invented for (i.e. the\ncontents of the file in the working tree itself need to be adjusted\nin the working tree and in the repository, hence there is a filter\nin each direction).  As the mechanism being \"filter\", i.e. a\nbytestream is converted into another bytestream, it is not even\ndesigned to muck with other things on the filesystem.\n\n\n"}]}