git2-rs icon indicating copy to clipboard operation
git2-rs copied to clipboard

Mismatched binary detection behaviour on diffs

Open FintanH opened this issue 2 years ago • 5 comments

Hey :wave:

I have a peculiar case that I've created a reproducible for. If you clone this repository https://github.com/FintanH/git2-binary-check and do cargo run, you'll get the following output:

Path: "bin/cat"
Is binary: false
Path: "bin/ls"
Is binary: false
Path: "bin/test"
Is binary: false

However, if you were to run git diff 373b3404371e359404392aff715d504293112c8b abdedcec89e3c48ac520e4a96c7ea39364316b9e, you'll get:

diff --git a/bin/cat b/bin/cat
new file mode 100755
index 0000000..0bbb14b
Binary files /dev/null and b/bin/cat differ
diff --git a/bin/ls b/bin/ls
new file mode 100755
index 0000000..87c2d51
Binary files /dev/null and b/bin/ls differ
diff --git a/bin/test b/bin/test
new file mode 100755
index 0000000..0cced79
Binary files /dev/null and b/bin/test differ

It seems like git2, and possibly libgit2, are not detecting binary files in the same manner as the git CLI is doing.

I checked on git2-0.17.0 and git2-018.1 and my git version is git version 2.40.1.

Let me know if I can do anything else to help track down this discrepancy.

FintanH avatar Sep 22 '23 07:09 FintanH

and possibly libgit2

then its probably better to post the repro there

extrawurst avatar Sep 22 '23 08:09 extrawurst

and possibly libgit2

then its probably better to post the repro there

Thanks for the response, you're right. My C is rusty (pun intended), so it was quicker for me to write a reproducible in Rust first -- and since this library directly relies on the behaviour of libgit2 I thought it would be in this project's interest to know about the potential bug too :)

FintanH avatar Sep 22 '23 08:09 FintanH

people post the git2-rs based rust repros there too, don't be shy :)

extrawurst avatar Sep 22 '23 08:09 extrawurst

The main.rs in the repo only prints "Hello, world!". Is it perhaps missing the reproduction code?

ehuss avatar Sep 22 '23 13:09 ehuss

Ah sorry! I did forget to push the changes, but they're there now, thanks :bow:

FintanH avatar Sep 22 '23 13:09 FintanH