import subprocess

W = r"C:/Users/decid/Documents/projects/spt-core/.worktrees/shape-0680"
path = "docs-site/src/cli/reference.md"

work = open(f"{W}/{path}", "rb").read()
blob = subprocess.run(["git", "-C", W, "show", f"HEAD:{path}"], capture_output=True).stdout

print(f"working copy : {len(work):8} bytes  CR={work.count(b0) if False else work.count(bytes([13])):6}  LF={work.count(bytes([10])):6}")
print(f"HEAD blob    : {len(blob):8} bytes  CR={blob.count(bytes([13])):6}  LF={blob.count(bytes([10])):6}")
print()
norm_work = work.replace(bytes([13, 10]), bytes([10]))
norm_blob = blob.replace(bytes([13, 10]), bytes([10]))
print(f"identical raw            : {work == blob}")
print(f"identical after CRLF->LF : {norm_work == norm_blob}")
if norm_work != norm_blob:
    print("CONTENT DIFFERS - there is real work here to preserve")
else:
    print("CONTENT IDENTICAL - the 'M' flag is line endings only; nothing at risk")
