Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

strip newlines from tree entry names #130

Closed
wants to merge 1 commit into from

3 participants

@technoweenie
Collaborator

ported from github.com

@bkeepers
Collaborator

Grit is no longer maintained. See #183 and check out libgit2/rugged.

@bkeepers bkeepers closed this
@bkeepers bkeepers deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 3, 2012
  1. @vmg @technoweenie

    strip newlines from tree entry names

    vmg authored technoweenie committed
    ported from github.com
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/grit/git-ruby/git_object.rb
View
7 lib/grit/git-ruby/git_object.rb
@@ -125,6 +125,11 @@ def initialize(mode, filename, sha1o)
end
end
+ # Filenames can have weird characters that throw grit's text parsing
+ def safe_name
+ name.gsub(/[\r\n\0]/, '')
+ end
+
def type
case @mode & S_IFMT
when S_IFGITLINK
@@ -223,7 +228,7 @@ def type
def raw_content
# TODO: sort correctly
#@entry.sort { |a,b| a.name <=> b.name }.
- @entry.collect { |e| [[e.format_mode, e.format_type, e.sha1].join(' '), e.name].join("\t") }.join("\n")
+ @entry.collect { |e| [[e.format_mode, e.format_type, e.sha1].join(' '), e.safe_name].join("\t") }.join("\n")
end
def actual_raw
Something went wrong with that request. Please try again.