{"thread":{"id":"48402","subject":"Blame / annotate with mixed mac line endings?","startedAt":"2018-05-03T00:27:48Z","lastAt":"2018-05-03T04:56:00Z","messageCount":4,"participants":["Jason Pyeron","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"346486","messageId":"B8114616E07247C7A78F1DFF91E16A63@ad.pdinc.us","threadId":"48402","inReplyTo":null,"subject":"Blame / annotate with mixed mac line endings?","fromName":"Jason Pyeron","fromEmail":"jpyeron@pdinc.us","sentAt":"2018-05-02T23:57:28Z","receivedAt":"2018-05-03T00:27:48Z","isPatch":false,"sender":{"key":"jpyeron@pdinc.us","avatar":"https://gravatar.com/avatar/c2e53452caa53d940768a1ffc9cf76196d851b9b534b7a39cd39852a70a0508f?d=mp&s=160"},"body":"I think this file may have been from a mac at one point. Note the lone CR (0x0d) line endings, with CRLFs later.\n\n$ cat src/htdocs/hr/ats/rpts/incl/slt_org.cfm | sed 's/[a-zA-Z]/x/g;s/[0-9]/8/g' | hexdump -C\n00000000  3c 21 2d 2d 2d 0d 78 78  78 78 78 78 78 78 3a 20  |<!---.xxxxxxxx: |\n00000010  78 78 78 5f 78 78 78 2e  78 78 78 0d 78 78 78 78  |xxx_xxx.xxx.xxxx|\n00000020  78 78 3a 0d 78 78 78 78  78 78 78 3a 20 38 38 2f  |xx:.xxxxxxx: 88/|\n00000030  38 38 2f 38 38 38 38 20  38 38 3a 38 38 3a 38 38  |88/8888 88:88:88|\n00000040  20 78 78 0d 78 78 78 78  78 78 78 78 3a 20 38 38  | xx.xxxxxxxx: 88|\n00000050  2f 38 38 2f 38 38 38 38  20 38 38 3a 38 38 3a 38  |/88/8888 88:88:8|\n00000060  38 20 78 78 0d 78 78 78  78 78 78 78 78 78 78 78  |8 xx.xxxxxxxxxxx|\n00000070  3a 0d 2d 2d 2d 3e 0d 0d  3c 78 78 78 78 78 78 20  |:.--->..<xxxxxx |\n00000080  78 78 78 78 3d 22 78 78  78 5f 78 78 78 5f 78 78  |xxxx=\"xxx_xxx_xx|\n00000090  78 78 22 20 78 78 78 78  3d 22 38 22 20 78 78 78  |xx\" xxxx=\"8\" xxx|\n000000a0  78 78 78 78 78 3e 0d 0a  09 3c 78 78 78 78 78 78  |xxxxx>...<xxxxxx|\n000000b0  20 78 78 78 78 78 3d 22  22 3e 2d 20 78 78 78 78  | xxxxx=\"\">- xxxx|\n000000c0  78 78 20 78 78 78 20 78  78 20 78 78 78 78 2d 3c  |xx xxx xx xxxx-<|\n000000d0  2f 78 78 78 78 78 78 3e  0d 0a 09 3c 78 78 78 78  |/xxxxxx>...<xxxx|\n000000e0  20 78 78 78 2e 78 78 78  78 78 78 78 78 78 78 20  | xxx.xxxxxxxxxx |\n000000f0  78 78 78 20 38 20 78 78  20 78 78 78 78 2e 78 78  |xxx 8 xx xxxx.xx|\n00000100  78 78 78 78 78 78 78 20  78 78 20 27 78 78 38 78  |xxxxxxx xx 'xx8x|\n00000110  27 3e 0d 0a 09 3c 78 78  78 78 78 78 20 78 78 78  |'>...<xxxxxx xxx|\n00000120  78 78 3d 22 3c 78 78 78  78 78 78 78 78 20 78 78  |xx=\"<xxxxxxxx xx|\n00000130  78 78 78 3d 22 78 78 78  78 78 78 78 78 78 78 22  |xxx=\"xxxxxxxxxx\"|\n00000140  3e 23 78 78 78 5f 78 78  78 23 2c 3c 2f 78 78 78  |>#xxx_xxx#,</xxx|\n00000150  78 78 78 78 78 3e 78 78  78 22 3e 78 78 78 3c 2f  |xxxxx>xxx\">xxx</|\n00000160  78 78 78 78 78 78 3e 0d  0a 09 3c 2f 78 78 78 78  |xxxxxx>...</xxxx|\n00000170  3e 0d 0a 3c 78 78 78 78  78 78 78 78 20 78 78 78  |>..<xxxxxxxx xxx|\n00000180  78 78 3d 22 78 78 78 78  78 78 78 78 78 78 22 3e  |xx=\"xxxxxxxxxx\">|\n00000190  0d 0a 09 3c 78 78 78 78  78 78 20 78 78 78 78 78  |...<xxxxxx xxxxx|\n000001a0  3d 22 23 78 78 78 5f 78  78 78 23 22 3e 23 78 78  |=\"#xxx_xxx#\">#xx|\n000001b0  78 5f 78 78 78 23 3c 2f  78 78 78 78 78 78 3e 0d  |x_xxx#</xxxxxx>.|\n000001c0  0a 3c 2f 78 78 78 78 78  78 78 78 3e 0d 0a 3c 2f  |.</xxxxxxxx>..</|\n000001d0  78 78 78 78 78 78 3e 0d  0a 0d 0a                 |xxxxxx>....|\n000001db\n\n$ git annotate -L 13,17 --line-porcelain 'src/htdocs/hr/ats/rpts/incl/slt_org.cfm'\nfatal: file src/htdocs/hr/ats/rpts/incl/slt_org.cfm has only 10 lines\n\n$ cat src/htdocs/hr/ats/rpts/incl/slt_org.cfm | wc -l\n10\n\n$ cat src/htdocs/hr/ats/rpts/incl/slt_org.cfm | mac2unix | wc -l\n18\n\n$ git -c core.autocrlf=false -c core.eol=cr annotate -L 13,17 --line-porcelain 'src/htdocs/hr/ats/rpts/incl/slt_org.cfm'\nfatal: file src/htdocs/hr/ats/rpts/incl/slt_org.cfm has only 10 lines\n\nAny way to hit git with a stick to treat lone CR as a line break for blame/annotate?\n\n-Jason\n\n--\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n-                                                               -\n- Jason Pyeron                      PD Inc. http://www.pdinc.us -\n- Principal Consultant              10 West 24th Street #100    -\n- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -\n-                                                               -\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n"},{"id":"346495","messageId":"xmqqh8npv8hy.fsf@gitster-ct.c.googlers.com","threadId":"48402","inReplyTo":"B8114616E07247C7A78F1DFF91E16A63@ad.pdinc.us","subject":"Re: Blame / annotate with mixed mac line endings?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-03T01:22:01Z","receivedAt":"2018-05-03T01:22:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Jason Pyeron\" <jpyeron@pdinc.us> writes:\n\n> Any way to hit git with a stick to treat lone CR as a line break for blame/annotate?\n\nI highly suspect that you would get more help from those whose love\nis Git if your inquiry were about a way to ask Git politely to do\nwhat you want to achieve, rather than hitting it with a stick ;-)\n\nPerhaps define a textconv filter to fix the incorrect line endings?\nThat way, you do not have to rewrite the history only to run blame,\nbut can pretend as if the contents were all using consistent line\nendings (either LF or CRLF) retroactively.\n\n"},{"id":"346497","messageId":"8957C3B9BEF94443ABE0A67340786A86@ad.pdinc.us","threadId":"48402","inReplyTo":"xmqqh8npv8hy.fsf@gitster-ct.c.googlers.com","subject":"RE: Blame / annotate with mixed mac line endings?","fromName":"Jason Pyeron","fromEmail":"jpyeron@pdinc.us","sentAt":"2018-05-03T02:32:05Z","receivedAt":"2018-05-03T02:33:08Z","isPatch":false,"sender":{"key":"jpyeron@pdinc.us","avatar":"https://gravatar.com/avatar/c2e53452caa53d940768a1ffc9cf76196d851b9b534b7a39cd39852a70a0508f?d=mp&s=160"},"body":"> -----Original Message-----\n> From: Junio C Hamano\n> Sent: Wednesday, May 2, 2018 21:22\n> Subject: Re: Blame / annotate with mixed mac line endings?\n> \n> \"Jason Pyeron\" <jpyeron@pdinc.us> writes:\n> \n> > Any way to hit git with a stick to treat lone CR as a line \n> break for blame/annotate?\n\n> I highly suspect that you would get more help from those whose love\n> is Git if your inquiry were about a way to ask Git politely to do\n> what you want to achieve, rather than hitting it with a stick ;-)\n\nNo offense meant.\n\n> Perhaps define a textconv filter to fix the incorrect line endings?\n\nWorked perfectly! I Read:\n\nhttps://github.com/git/git/blob/master/t/t8006-blame-textconv.sh\n\nAdded to .git/config:\n\n[diff \"test\"]\n        textconv = /usr/local/bin/helper.sh\n\nAdded to .gitattributes:\n*.cfm diff=test\n\n$ cat /usr/local/bin/helper.sh\ncat \"$1\" | mac2unix\n\nThe important issue was to not use mac2unix directly, because it modifies the file itself.\n\nRead: https://git.wiki.kernel.org/index.php/Textconv but it did not help so much.\n\nThanks,\n\nJason\n\n--\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n-                                                               -\n- Jason Pyeron                      PD Inc. http://www.pdinc.us -\n- Principal Consultant              10 West 24th Street #100    -\n- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -\n-                                                               -\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- \n\n"},{"id":"346498","messageId":"xmqqd0yduylh.fsf@gitster-ct.c.googlers.com","threadId":"48402","inReplyTo":"8957C3B9BEF94443ABE0A67340786A86@ad.pdinc.us","subject":"Re: Blame / annotate with mixed mac line endings?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-03T04:55:54Z","receivedAt":"2018-05-03T04:56:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Jason Pyeron\" <jpyeron@pdinc.us> writes:\n\n> $ cat /usr/local/bin/helper.sh\n> cat \"$1\" | mac2unix\n>\n> The important issue was to not use mac2unix directly, because it\n> modifies the file itself.\n\nI wonder if\n\n[diff \"test\"]\n\ttextconv = sh -c 'mac2unix <\"$1\"' -IAmArgv0-\n\nworks without an extra helper.\n\n"}]}