Skip to content
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

Diff fails with NoMethodError: undefined method '[]' for nil:NilClass when line ending warnings are emitted #112

Open
glennsarti opened this issue Feb 23, 2017 · 0 comments

Comments

@glennsarti
Copy link
Contributor

From ruby-git/ruby-git#326

Repro case:

  • Download a repository which contains a file with CRLF endings on an operating system that uses LF endings
  • Extracting the diff will throw a NoMethodError: undefined method '[]' for nil:NilClass error in method process_full_diff

Example output;

Overriding any local changes to repositories in modules
Not managing Rakefile in puppetlabs-chocolatey
Not managing spec/spec_helper.rb in puppetlabs-chocolatey
Using no-op. Files in puppetlabs-chocolatey may be changed but will not be committed.
Files changed:
Error while updating puppetlabs-chocolatey
bundler: failed to load command: msync (/mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/bin/msync)
NoMethodError: undefined method `[]' for nil:NilClass
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/gems/git-1.3.0/lib/git/diff.rb:151:in `block in process_full_diff'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/gems/git-1.3.0/lib/git/diff.rb:134:in `each'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/gems/git-1.3.0/lib/git/diff.rb:134:in `process_full_diff'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/gems/git-1.3.0/lib/git/diff.rb:109:in `process_full'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/gems/git-1.3.0/lib/git/diff.rb:68:in `each'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/bundler/gems/modulesync-899483f48304/lib/modulesync/git.rb:162:in `update_noop'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/bundler/gems/modulesync-899483f48304/lib/modulesync.rb:114:in `manage_module'
  /mnt/c/Source/modulesync_configs/.bundle/bash/ruby/2.3.0/bundler/gems/modulesync-899483f48304/lib/modulesync.rb:133:in `block in update'

The reason it fails because the code at; https://github.com/schacon/ruby-git/blob/master/lib/git/diff.rb#L139-L151 expects the first line to contain the filename whereas raw diff comes back as;

warning: CRLF will be replaced by LF in examples/init.pp.
The file will have its original line endings in your working directory.
diff --git a/.gitattributes b/.gitattributes
index 900ea0c..02d4646 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,5 @@
 #This file is generated by ModuleSync, do not edit.

This issue is track the monkey patch that is in #111 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant