-
Notifications
You must be signed in to change notification settings - Fork 533
diff
breaks for patches
#196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is there any public repo to reproduce this? Working good locally so far. The only way to get the deleted type would be to use Can you try to set the HEAD to the sha where the file was first created and run a diff like this: That would be bulletproof. Your Git version would be useful too. Does a command line |
Sorry for not including steps to reproduce, but here you go: $ git clone https://github.com/isaacs/readable-stream
$ cd readable-stream
$ irb irb> require 'git'
irb> repo = Git.open('.')
irb> diff = repo.diff('5aec72b01618ddfc46ad09cdbc66dc8d26211e52', 'c49f6387e8de23dd8da96b513037ca99800014c3')
irb> diff.map(&:type)
[ ..., "+deleted", ... ] |
Funny (?) cuz yours is just the tip of the iceberg. Any file line, within any kind of file, containing Also, any line containing It's weird that an
I'll create some tests. I think we can easily prevent problems Ideally the parsing logic should be improved to detect context and forget about specifics within those. Working on it.... |
Damn, you can even "create files" that do not even exist by adding/having lines following Basically .patch files, logs, or things like that can create tons of invalid diff entires if they are included. in the diff output. |
Opening a new issue for a general refactor of the thing. Anyways, all the previously listed scenarios should be fixed. |
Tests e55f3bd |
Thanks @robertodecurnex. Verified it works on my end. |
If a commit contains a
.patch
, the parsing logic for https://github.com/schacon/ruby-git/blob/master/lib/git/diff.rb#L132 fails. It'll start reporting, for example:type: '-deleted'
. The patch in a diff will be printed out as-deleted file mode 100644
.To reproduce, try committing https://github.com/isaacs/readable-stream/blob/master/float.patch and do
repo.diff(prev_commit, head_commit)
The text was updated successfully, but these errors were encountered: