Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ ar_force_convert_table(VALUE hash, const char *file, int line)
RUBY_ASSERT(rb_gc_obj_slot_size(hash) >= sizeof(struct RHash) + sizeof(ar_table));

// prepare hash values
do {
while (1) {
st_data_t keys[RHASH_AR_TABLE_MAX_SIZE];
bound = RHASH_AR_TABLE_BOUND(hash);
size = RHASH_AR_TABLE_SIZE(hash);
Expand All @@ -727,7 +727,9 @@ ar_force_convert_table(VALUE hash, const char *file, int line)
if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) return RHASH_ST_TABLE(hash);
if (UNLIKELY(RHASH_AR_TABLE_BOUND(hash) != bound)) continue;
if (UNLIKELY(ar_each_key(ar, bound, ar_each_key_cmp, keys, NULL, NULL))) continue;
} while (0);

break;
}

// make st
st_table tab;
Expand Down
12 changes: 8 additions & 4 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,6 @@ def write_lock(file, preserve_unknown_sections)

contents = to_lock

# Convert to \r\n if the existing lock has them
# i.e., Windows with `git config core.autocrlf=true`
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match?("\r\n")

if @locked_bundler_version
locked_major = @locked_bundler_version.segments.first
current_major = bundler_version_to_lock.segments.first
Expand All @@ -427,6 +423,14 @@ def write_lock(file, preserve_unknown_sections)
return
end

# Convert to \r\n if the existing lock has them, i.e., Windows with
# `git config core.autocrlf=true`. Detect from the bytes on disk because
# reading in text mode strips carriage returns on Windows, which would
# otherwise defeat this check and rewrite a `\r\n` lockfile with `\n`.
if File.exist?(file) && SharedHelpers.filesystem_access(file, :read) {|p| File.binread(p).include?("\r\n") }
contents.gsub!(/\n/, "\r\n")
end

begin
SharedHelpers.filesystem_access(file) do |p|
File.open(p, "wb") {|f| f.puts(contents) }
Expand Down
2 changes: 0 additions & 2 deletions spec/bundler/install/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
end

it "works when you bundle exec bundle" do
skip "doesn't find bundle" if Gem.win_platform?

bundle :install
bundle_config "deployment true"
bundle :install
Expand Down
4 changes: 0 additions & 4 deletions spec/bundler/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,6 @@
context "when the branch starts with a `#`" do
let(:branch) { "#149/redirect-url-fragment" }
it "works" do
skip "git does not accept this" if Gem.win_platform?

update_git("foo", path: repo, branch: branch)

install_gemfile <<-G
Expand Down Expand Up @@ -481,8 +479,6 @@
context "when the tag starts with a `#`" do
let(:tag) { "#149/redirect-url-fragment" }
it "works" do
skip "git does not accept this" if Gem.win_platform?

update_git("foo", path: repo, tag: tag)

install_gemfile <<-G
Expand Down
2 changes: 0 additions & 2 deletions spec/bundler/install/yanked_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
end

before do
skip "Materialization on Windows is not yet strict, so the example does not detect the gem has been yanked" if Gem.win_platform?

build_repo4 do
build_gem "foo", "1.0.0"
build_gem "foo", "1.0.1"
Expand Down
8 changes: 3 additions & 5 deletions spec/bundler/lock/lockfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2335,9 +2335,7 @@ def set_lockfile_mtime_to_known_value
expect(the_bundle).to include_gems "myrack 1.2"
end

it "preserves Gemfile.lock \\n\\r line endings" do
skip "needs to be adapted" if Gem.win_platform?

it "preserves Gemfile.lock \\r\\n line endings" do
update_repo2 do
build_gem "myrack", "1.2" do |s|
s.executables = "myrackup"
Expand All @@ -2349,7 +2347,7 @@ def set_lockfile_mtime_to_known_value
set_lockfile_mtime_to_known_value

expect { bundle "update", all: true }.to change { File.mtime(bundled_app_lock) }
expect(File.read(bundled_app_lock)).to match("\r\n")
expect(File.binread(bundled_app_lock)).to match("\r\n")

expect(the_bundle).to include_gems "myrack 1.2"
end
Expand All @@ -2365,7 +2363,7 @@ def set_lockfile_mtime_to_known_value
end.not_to change { File.mtime(bundled_app_lock) }
end

it "preserves Gemfile.lock \\n\\r line endings" do
it "preserves Gemfile.lock \\r\\n line endings" do
win_lock = File.read(bundled_app_lock).gsub(/\n/, "\r\n")
File.open(bundled_app_lock, "wb") {|f| f.puts(win_lock) }
set_lockfile_mtime_to_known_value
Expand Down
10 changes: 8 additions & 2 deletions test/ruby/test_gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,14 @@ def test_stat_argument
def test_stat_single
omit 'stress' if GC.stress

stat = GC.stat
assert_equal stat[:count], GC.stat(:count)
# GC.stat and GC.stat(:count) are two separate reads of :count. If a GC
# runs between them (e.g. triggered by an allocation on another thread),
# :count changes and the two reads disagree. Disable GC so both reads
# observe the same :count.
EnvUtil.without_gc do
stat = GC.stat
assert_equal stat[:count], GC.stat(:count)
end
assert_raise(ArgumentError){ GC.stat(:invalid) }
end

Expand Down