Skip to content

Commit 3102ca4

Browse files
committed
Default GIT external encoding to UTF-8 🤷‍♂️
And dump the title as US-ASCII.
1 parent 17af8bf commit 3102ca4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tool/file2lastrev.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def self.output=(output)
5959
when :revision_h
6060
Proc.new {|last, changed, modified, branch, title|
6161
short = vcs.short_revision(last)
62+
if /[^\x00-\x7f]/ =~ title and title.respond_to?(:force_encoding)
63+
title = title.dup.force_encoding("US-ASCII")
64+
end
6265
[
6366
"#define RUBY_REVISION #{short.inspect}",
6467
("#define RUBY_FULL_REVISION #{last.inspect}" unless short == last),

tool/vcs.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def self.popen(command, *rest, &block)
3232
if opts.kind_of?(Hash)
3333
dir = opts.delete(:chdir)
3434
rest.pop if opts.empty?
35+
opts.delete(:external_encoding)
3536
end
3637

3738
if block
@@ -66,6 +67,7 @@ def self.popen(command, *rest, &block)
6667
if opts.kind_of?(Hash)
6768
dir = opts.delete(:chdir)
6869
rest.pop if opts.empty?
70+
opts.delete(:external_encoding)
6971
end
7072

7173
command = command.shelljoin if Array === command
@@ -384,8 +386,9 @@ class GIT < self
384386
COMMAND = ENV["GIT"] || 'git'
385387

386388
def self.cmd_args(cmds, srcdir = nil)
389+
(opts = cmds.last).kind_of?(Hash) or cmds << (opts = {})
390+
opts[:external_encoding] ||= "UTF-8"
387391
if srcdir and local_path?(srcdir)
388-
(opts = cmds.last).kind_of?(Hash) or cmds << (opts = {})
389392
opts[:chdir] ||= srcdir
390393
end
391394
cmds

0 commit comments

Comments
 (0)