{"action":"created","issue":{"url":"https://api.github.com/repos/schacon/ruby-git/issues/188","labels_url":"https://api.github.com/repos/schacon/ruby-git/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/schacon/ruby-git/issues/188/comments","events_url":"https://api.github.com/repos/schacon/ruby-git/issues/188/events","html_url":"https://github.com/schacon/ruby-git/issues/188","id":46832929,"number":188,"title":"`split': invalid byte sequence in UTF-8 (ArgumentError)","user":{"login":"jatinganhotra","id":307606,"avatar_url":"https://avatars.githubusercontent.com/u/307606?v=3","gravatar_id":"","url":"https://api.github.com/users/jatinganhotra","html_url":"https://github.com/jatinganhotra","followers_url":"https://api.github.com/users/jatinganhotra/followers","following_url":"https://api.github.com/users/jatinganhotra/following{/other_user}","gists_url":"https://api.github.com/users/jatinganhotra/gists{/gist_id}","starred_url":"https://api.github.com/users/jatinganhotra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jatinganhotra/subscriptions","organizations_url":"https://api.github.com/users/jatinganhotra/orgs","repos_url":"https://api.github.com/users/jatinganhotra/repos","events_url":"https://api.github.com/users/jatinganhotra/events{/privacy}","received_events_url":"https://api.github.com/users/jatinganhotra/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/schacon/ruby-git/labels/Bug","name":"Bug","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-10-26T05:29:54Z","updated_at":"2015-03-24T15:26:47Z","closed_at":null,"body":"Hi,\r\n\r\nFor a project, I'm storing diffs for each commit in forms of difffiles (diff per file) and patches, including the stats for each patch.\r\n\r\nMy script starts like - \r\n```\r\nrequire 'rubygems'\r\nrequire 'logger'\r\nrequire 'rugged'\r\nrequire 'git'\r\n\r\n# Include diff, difffile classes\r\nload 'diff.rb'\r\nload 'difffile.rb'\r\nload 'helper.rb'\r\n\r\n# Global array to store all the diffs\r\ndiffs_array = []\r\n\r\n# Initialize both libraries\r\nworking_dir = `pwd`.chomp\r\nrubygit_gem_repo = Git.open(working_dir, :log => Logger.new(STDOUT))\r\nrugged_repo = Rugged::Repository.new(working_dir)\r\n\r\n# Get all the commits for the project\r\ncommit_list = rubygit_gem_repo.log(nil)\r\n\r\n# Get the initial empty tree state\r\nempty_tree=`git hash-object -w -t tree /dev/null`\r\nempty_state = rugged_repo.lookup(\"#{empty_tree.chomp}\")\r\n\r\ncommit_list_array = commit_list.to_a\r\n```\r\nFor 2 commits, I calculate the diff as follows:\r\n```\r\n  diff_bw_commits = rubygit_gem_repo.diff(prev_sha, next_sha)\r\n  diff = Diff.new(prev_sha, next_sha, diff_bw_commits)\r\n  diff.generate_difffiles_and_stats\r\n```\r\nIn the generate_difffiles_and_stats function, I'm doing the following:\r\n```\r\n@difffiles = []\r\n    # diff.class => Git::Diff\r\n    # Get the stats for the diff, before extracting individual difffiles\r\n    @stats = @diff.stats\r\n    diff = @diff.to_a\r\n    \r\n    self.generate_stats\r\n    @num_difffiles = diff.size\r\n    @num_difffiles.times do |i|\r\n      difffile = DiffFile.new( diff[i] )\r\n      @difffiles << difffile\r\n    end\r\n```\r\n  \r\nMy script runs fine for simple commit histories that I created myself, but when I run it on project JSHint, I'm getting an error:\r\n```\r\n</CreationDate(D:20120619174250-04'00')/Creator(Adobe Illustrator CS5.1)/ModDat0000000000 65535 f-04'00')/Producer(Adobe PDF library 9.90)/Title(jshint)>>\r\n+0000000016 00000 n\r\n+0000000144 00000 n\r\n+0001070928 00000 n\r\n<</Size 32/Root 1 0 R/Info 31 0 R/ID[<6BDD672972174366B9A561E955D8F759><CE113017%%EOF00efBA27BDB89A4EB25>]>>\r\n\\ No newline at end of file\r\n/Users/jatinganhotra/.rvm/gems/ruby-2.1.3@527project/gems/git-1.2.8/lib/git/diff.rb:121:in `split': invalid byte sequence in UTF-8 (ArgumentError)\r\n\tfrom /Users/jatinganhotra/.rvm/gems/ruby-2.1.3@527project/gems/git-1.2.8/lib/git/diff.rb:121:in `process_full_diff'\r\n\tfrom /Users/jatinganhotra/.rvm/gems/ruby-2.1.3@527project/gems/git-1.2.8/lib/git/diff.rb:107:in `process_full'\r\n\tfrom /Users/jatinganhotra/.rvm/gems/ruby-2.1.3@527project/gems/git-1.2.8/lib/git/diff.rb:64:in `each'\r\n\tfrom diff.rb:57:in `to_a'\r\n\tfrom diff.rb:57:in `generate_difffiles_and_stats'\r\n\tfrom script.rb:48:in `block in <main>'\r\n\tfrom script.rb:32:in `each'\r\n\tfrom script.rb:32:in `<main>'\r\n```\r\n\r\nI researched about the error and found that the issue can be fixed by the answer in this [StackOverflow answer](http://stackoverflow.com/a/10466273/355722).  \r\nIs it something that I am doing wrong?\r\nPlease let me know if you need any more information.\r\n\r\nP.S. I know that this gem is not under active development, but it very nicely breaks down a Diff to Difffile to Patch. I can also easily access stats for each commit and stats per file. So, I stick to using it for diff purposes. I looked at the Rugged gem, but couldn't find such functionality. So, I just love this gem for this :)"},"comment":{"url":"https://api.github.com/repos/schacon/ruby-git/issues/comments/85553743","html_url":"https://github.com/schacon/ruby-git/issues/188#issuecomment-85553743","issue_url":"https://api.github.com/repos/schacon/ruby-git/issues/188","id":85553743,"user":{"login":"matthutchinson","id":2095,"avatar_url":"https://avatars.githubusercontent.com/u/2095?v=3","gravatar_id":"","url":"https://api.github.com/users/matthutchinson","html_url":"https://github.com/matthutchinson","followers_url":"https://api.github.com/users/matthutchinson/followers","following_url":"https://api.github.com/users/matthutchinson/following{/other_user}","gists_url":"https://api.github.com/users/matthutchinson/gists{/gist_id}","starred_url":"https://api.github.com/users/matthutchinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthutchinson/subscriptions","organizations_url":"https://api.github.com/users/matthutchinson/orgs","repos_url":"https://api.github.com/users/matthutchinson/repos","events_url":"https://api.github.com/users/matthutchinson/events{/privacy}","received_events_url":"https://api.github.com/users/matthutchinson/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T15:26:47Z","updated_at":"2015-03-24T15:26:47Z","body":"I think it's no longer mergable due to conflicts, maybe rebase with upstream master and push again.."}}