From 4df8636c388ccaadaecabb7e146d306de43063e5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 16 Apr 2014 15:32:31 -0700 Subject: [PATCH] core: instantiate all keys in a V2 config prior to merging This forces everything to get a new instance, so we don't accidentally overwrite any values across multiple machines. --- lib/vagrant/config/v2/loader.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vagrant/config/v2/loader.rb b/lib/vagrant/config/v2/loader.rb index b0c833982..1fd87c069 100644 --- a/lib/vagrant/config/v2/loader.rb +++ b/lib/vagrant/config/v2/loader.rb @@ -51,6 +51,16 @@ module Vagrant old_state = old.__internal_state new_state = new.__internal_state + # Make sure we instantiate every key in the config so that we + # merge every key. This avoids issues with the same reference + # being part of the config. + old_state["config_map"].each do |k, _| + old.send(k) + end + new_state["config_map"].each do |k, _| + new.send(k) + end + # The config map for the new object is the old one merged with the # new one. config_map = old_state["config_map"].merge(new_state["config_map"])