All of lore.kernel.org
 help / color / mirror / Atom feed
* Blame / annotate with mixed mac line endings?
@ 2018-05-02 23:57 Jason Pyeron
  2018-05-03  1:22 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Pyeron @ 2018-05-02 23:57 UTC (permalink / raw)
  To: git

I think this file may have been from a mac at one point. Note the lone CR (0x0d) line endings, with CRLFs later.

$ cat src/htdocs/hr/ats/rpts/incl/slt_org.cfm | sed 's/[a-zA-Z]/x/g;s/[0-9]/8/g' | hexdump -C
00000000  3c 21 2d 2d 2d 0d 78 78  78 78 78 78 78 78 3a 20  |<!---.xxxxxxxx: |
00000010  78 78 78 5f 78 78 78 2e  78 78 78 0d 78 78 78 78  |xxx_xxx.xxx.xxxx|
00000020  78 78 3a 0d 78 78 78 78  78 78 78 3a 20 38 38 2f  |xx:.xxxxxxx: 88/|
00000030  38 38 2f 38 38 38 38 20  38 38 3a 38 38 3a 38 38  |88/8888 88:88:88|
00000040  20 78 78 0d 78 78 78 78  78 78 78 78 3a 20 38 38  | xx.xxxxxxxx: 88|
00000050  2f 38 38 2f 38 38 38 38  20 38 38 3a 38 38 3a 38  |/88/8888 88:88:8|
00000060  38 20 78 78 0d 78 78 78  78 78 78 78 78 78 78 78  |8 xx.xxxxxxxxxxx|
00000070  3a 0d 2d 2d 2d 3e 0d 0d  3c 78 78 78 78 78 78 20  |:.--->..<xxxxxx |
00000080  78 78 78 78 3d 22 78 78  78 5f 78 78 78 5f 78 78  |xxxx="xxx_xxx_xx|
00000090  78 78 22 20 78 78 78 78  3d 22 38 22 20 78 78 78  |xx" xxxx="8" xxx|
000000a0  78 78 78 78 78 3e 0d 0a  09 3c 78 78 78 78 78 78  |xxxxx>...<xxxxxx|
000000b0  20 78 78 78 78 78 3d 22  22 3e 2d 20 78 78 78 78  | xxxxx="">- xxxx|
000000c0  78 78 20 78 78 78 20 78  78 20 78 78 78 78 2d 3c  |xx xxx xx xxxx-<|
000000d0  2f 78 78 78 78 78 78 3e  0d 0a 09 3c 78 78 78 78  |/xxxxxx>...<xxxx|
000000e0  20 78 78 78 2e 78 78 78  78 78 78 78 78 78 78 20  | xxx.xxxxxxxxxx |
000000f0  78 78 78 20 38 20 78 78  20 78 78 78 78 2e 78 78  |xxx 8 xx xxxx.xx|
00000100  78 78 78 78 78 78 78 20  78 78 20 27 78 78 38 78  |xxxxxxx xx 'xx8x|
00000110  27 3e 0d 0a 09 3c 78 78  78 78 78 78 20 78 78 78  |'>...<xxxxxx xxx|
00000120  78 78 3d 22 3c 78 78 78  78 78 78 78 78 20 78 78  |xx="<xxxxxxxx xx|
00000130  78 78 78 3d 22 78 78 78  78 78 78 78 78 78 78 22  |xxx="xxxxxxxxxx"|
00000140  3e 23 78 78 78 5f 78 78  78 23 2c 3c 2f 78 78 78  |>#xxx_xxx#,</xxx|
00000150  78 78 78 78 78 3e 78 78  78 22 3e 78 78 78 3c 2f  |xxxxx>xxx">xxx</|
00000160  78 78 78 78 78 78 3e 0d  0a 09 3c 2f 78 78 78 78  |xxxxxx>...</xxxx|
00000170  3e 0d 0a 3c 78 78 78 78  78 78 78 78 20 78 78 78  |>..<xxxxxxxx xxx|
00000180  78 78 3d 22 78 78 78 78  78 78 78 78 78 78 22 3e  |xx="xxxxxxxxxx">|
00000190  0d 0a 09 3c 78 78 78 78  78 78 20 78 78 78 78 78  |...<xxxxxx xxxxx|
000001a0  3d 22 23 78 78 78 5f 78  78 78 23 22 3e 23 78 78  |="#xxx_xxx#">#xx|
000001b0  78 5f 78 78 78 23 3c 2f  78 78 78 78 78 78 3e 0d  |x_xxx#</xxxxxx>.|
000001c0  0a 3c 2f 78 78 78 78 78  78 78 78 3e 0d 0a 3c 2f  |.</xxxxxxxx>..</|
000001d0  78 78 78 78 78 78 3e 0d  0a 0d 0a                 |xxxxxx>....|
000001db

$ git annotate -L 13,17 --line-porcelain 'src/htdocs/hr/ats/rpts/incl/slt_org.cfm'
fatal: file src/htdocs/hr/ats/rpts/incl/slt_org.cfm has only 10 lines

$ cat src/htdocs/hr/ats/rpts/incl/slt_org.cfm | wc -l
10

$ cat src/htdocs/hr/ats/rpts/incl/slt_org.cfm | mac2unix | wc -l
18

$ git -c core.autocrlf=false -c core.eol=cr annotate -L 13,17 --line-porcelain 'src/htdocs/hr/ats/rpts/incl/slt_org.cfm'
fatal: file src/htdocs/hr/ats/rpts/incl/slt_org.cfm has only 10 lines

Any way to hit git with a stick to treat lone CR as a line break for blame/annotate?

-Jason

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Blame / annotate with mixed mac line endings?
  2018-05-02 23:57 Blame / annotate with mixed mac line endings? Jason Pyeron
@ 2018-05-03  1:22 ` Junio C Hamano
  2018-05-03  2:32   ` Jason Pyeron
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2018-05-03  1:22 UTC (permalink / raw)
  To: Jason Pyeron; +Cc: git

"Jason Pyeron" <jpyeron@pdinc.us> writes:

> Any way to hit git with a stick to treat lone CR as a line break for blame/annotate?

I highly suspect that you would get more help from those whose love
is Git if your inquiry were about a way to ask Git politely to do
what you want to achieve, rather than hitting it with a stick ;-)

Perhaps define a textconv filter to fix the incorrect line endings?
That way, you do not have to rewrite the history only to run blame,
but can pretend as if the contents were all using consistent line
endings (either LF or CRLF) retroactively.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Blame / annotate with mixed mac line endings?
  2018-05-03  1:22 ` Junio C Hamano
@ 2018-05-03  2:32   ` Jason Pyeron
  2018-05-03  4:55     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Pyeron @ 2018-05-03  2:32 UTC (permalink / raw)
  To: git; +Cc: 'Junio C Hamano'

> -----Original Message-----
> From: Junio C Hamano
> Sent: Wednesday, May 2, 2018 21:22
> Subject: Re: Blame / annotate with mixed mac line endings?
> 
> "Jason Pyeron" <jpyeron@pdinc.us> writes:
> 
> > Any way to hit git with a stick to treat lone CR as a line 
> break for blame/annotate?

> I highly suspect that you would get more help from those whose love
> is Git if your inquiry were about a way to ask Git politely to do
> what you want to achieve, rather than hitting it with a stick ;-)

No offense meant.

> Perhaps define a textconv filter to fix the incorrect line endings?

Worked perfectly! I Read:

https://github.com/git/git/blob/master/t/t8006-blame-textconv.sh

Added to .git/config:

[diff "test"]
        textconv = /usr/local/bin/helper.sh

Added to .gitattributes:
*.cfm diff=test

$ cat /usr/local/bin/helper.sh
cat "$1" | mac2unix

The important issue was to not use mac2unix directly, because it modifies the file itself.

Read: https://git.wiki.kernel.org/index.php/Textconv but it did not help so much.

Thanks,

Jason

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Blame / annotate with mixed mac line endings?
  2018-05-03  2:32   ` Jason Pyeron
@ 2018-05-03  4:55     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2018-05-03  4:55 UTC (permalink / raw)
  To: Jason Pyeron; +Cc: git

"Jason Pyeron" <jpyeron@pdinc.us> writes:

> $ cat /usr/local/bin/helper.sh
> cat "$1" | mac2unix
>
> The important issue was to not use mac2unix directly, because it
> modifies the file itself.

I wonder if

[diff "test"]
	textconv = sh -c 'mac2unix <"$1"' -IAmArgv0-

works without an extra helper.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-03  4:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-02 23:57 Blame / annotate with mixed mac line endings? Jason Pyeron
2018-05-03  1:22 ` Junio C Hamano
2018-05-03  2:32   ` Jason Pyeron
2018-05-03  4:55     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.