From 557ff6f7061164f68b85d56efb16325967ce2746 Mon Sep 17 00:00:00 2001 From: "Christopher M. Fuhrman" Date: Sun, 14 Apr 2013 15:31:36 -0700 Subject: [PATCH] Detect empty file list in commit and handle accordingly Should a git commit contain no file changes, a situation which is possible when the git repository has been converted from another SCM system such as Subversion, then assign an empty string to the list of files. This will prevent an exception caused when ruby tries to split a Nil object. Tested against git 1.8.0.1 and ruby 1.9.3 --- lib/vclog/adapters/git.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vclog/adapters/git.rb b/lib/vclog/adapters/git.rb index 3df8408..db8dbc2 100644 --- a/lib/vclog/adapters/git.rb +++ b/lib/vclog/adapters/git.rb @@ -37,7 +37,11 @@ def extract_changes changes.each do |entry| date, who, id, msg, files = entry.split(RUBY_FIELD_MARKER) date = Time.parse(date) - files = files.split("\n") + if files.nil? + files = [ "" ] + else + files = files.split("\n") + end list << Change.new(:id=>id, :date=>date, :who=>who, :msg=>msg, :files=>files) end @@ -178,7 +182,11 @@ def git_show(ref) who = who + ' ' + email date = Time.parse(date) - files = files.split("\n") + if files.nil? + files = [ "" ] + else + files = files.split("\n") + end return { :date=>date, :who=>who, :id=>id, :message=>msg, :files=>files } end