Diff.find_similar! misreports binary files as different
Open
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 2.3k
- Forks
- 293
- PR merge metrics
- No merged PRs in 30d
Description
Given the repository attached, and this small script:
require 'rugged'
repo = Rugged::Repository.new('repro/.git')
diff = Rugged::Tree.diff(repo,
repo.rev_parse('309dd700bcfa6de727c43f159013f5b109412669').tree,
repo.rev_parse('f010d6f0c3ede1d69ef387d63afc7cc334632c8e').tree,
show_binary: true)
diff.find_similar!
puts diff.map(&:to_s).join("\n")
The resulting diff shows this:
diff --git a/white.png b/rename.png
similarity index 100%
rename from white.png
rename to rename.png
Binary files a/white.png and b/rename.png differ
I did not expect the last line to appear, since the file was renamed in-place:
$ git show -p --binary f010d6f
commit f010d6f0c3ede1d69ef387d63afc7cc334632c8e (HEAD -> master)
Author: Joel Low <joel@joelsplace.sg>
Date: Thu Sep 28 14:20:15 2017 +0800
Rename binary file
diff --git a/white.png b/rename.png
similarity index 100%
rename from white.png
rename to rename.png
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior with the Ruby script in the issue and compare Diff.find_similar! output with the shown git show result. Start at the Diff.find_similar! entry point and trace binary-file handling; done means an in-place binary rename no longer reports an extra difference and the existing output matches Git.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, git, ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100