looksBinary reports whether content contains a NUL byte within the sniff window — the same marker git uses to report a file as binary.
(content []byte)
| 649 | // looksBinary reports whether content contains a NUL byte within the sniff |
| 650 | // window — the same marker git uses to report a file as binary. |
| 651 | func looksBinary(content []byte) bool { |
| 652 | if len(content) > binarySniffWindow { |
| 653 | content = content[:binarySniffWindow] |
| 654 | } |
| 655 | return bytes.IndexByte(content, 0) >= 0 |
| 656 | } |
| 657 | |
| 658 | func untrackedBinaryDiff(path string) string { |
| 659 | return fmt.Sprintf("diff --git a/%s b/%s\nnew file mode 100644\nBinary files /dev/null and b/%s differ\n", path, path, path) |