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)
| 643 | // looksBinary reports whether content contains a NUL byte within the sniff |
| 644 | // window — the same marker git uses to report a file as binary. |
| 645 | func looksBinary(content []byte) bool { |
| 646 | if len(content) > binarySniffWindow { |
| 647 | content = content[:binarySniffWindow] |
| 648 | } |
| 649 | return bytes.IndexByte(content, 0) >= 0 |
| 650 | } |
| 651 | |
| 652 | func untrackedBinaryDiff(path string) string { |
| 653 | 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) |