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

1.9 Error #4

Closed
trans opened this issue May 30, 2011 · 5 comments
Closed

1.9 Error #4

trans opened this issue May 30, 2011 · 5 comments

Comments

@trans
Copy link
Collaborator

trans commented May 30, 2011

I think I may have figured out what cases the problem under 1.9.x. Though a solution I have not yet figured out.

Running under 1.8.7 run_git gets:

"mktree"
"-z"
{:input=>["100644 blob 3c108a72a1f9e2b212b93a2449907c9fe733b2dd\tfull_list.js\000", "100644 blob 899e9ef139eac55023f859bc809aa8b92b893a8c\tapp.js\000", "100644 blob 6437874c699e26d29813936d16586cbdee7b8382\tjquery.js\000"]}
nil

Running under 1.9.2 it is:

"mktree"
"-z"
{:input=>["100644 blob 899e9ef139eac55023f859bc809aa8b92b893a8c\tapp.js\x00", "100644 blob 3c108a72a1f9e2b212b93a2449907c9fe733b2dd\tfull_list.js\x00", "100644 blob 6437874c699e26d29813936d16586cbdee7b8382\tjquery.js\x00"]}
nil

Since the error is "fatal: input format error" I suspect the problem is the difference between \x00 and \000 --an encoding issue.

Not that's all well and good, but despite over an hour of trying to figure out how to fix it I have had no success.

@duerst
Copy link

duerst commented Jul 25, 2011

This came up at [ruby-core:38466]. It's better called an escaping issue than an encoding issue. When moving from 1.8 to 1.9, the escaping in String#inspect was changed from octal (\000 for a null byte) to hexadecimal (\x00). This was done because these days, the average programmer is more familiar with hexadecimal than with octal notation (except for file permissions). In string literals, Ruby was always able to handle hexadecimal byte escapes. But it seems gash is using a hand-coded unescaping routine (better than using eval I guess, both for speed and for security), and that doesn't know hexadecimal escapes (which results in an "input format error"). Should not be too difficult to fix.

@nurse
Copy link

nurse commented Jul 25, 2011

This is because Array#to_s's change.

So it seems to need following changes:

diff --git a/lib/gash.rb b/lib/gash.rb
index 365c19c..65333b6 100644
--- a/lib/gash.rb
+++ b/lib/gash.rb
@@ -406,8 +406,6 @@ class Gash < SimpleDelegator
   end
   undef_method :dup

-  private
-  
   def find_repo(dir)
     Dir.chdir(dir) do
       File.expand_path(git('rev-parse', '--git-dir', :git_dir => false))
@@ -544,7 +542,7 @@ class Gash < SimpleDelegator
     reserr = ""
     status = Open4.popen4(*git_cmd) do |pid, stdin, stdout, stderr|
       if input = options.delete(:input)
-        stdin.write(input)
+        stdin.write(input.join)
       elsif block_given?
         yield stdin
       end

@shyouhei
Copy link

@nurse: click the edit button, and add 4 spaces at every beginning of lines.

@nurse
Copy link

nurse commented Jul 25, 2011

@shouhei: Oops, I did it, thanks

@trans
Copy link
Collaborator Author

trans commented Feb 17, 2012

I believe this is fixed now. Cane we get a new release?

@trans trans closed this as completed Feb 17, 2012
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

4 participants