summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2011-09-16 17:09:14 -0300
committerHisham Muhammad <hisham@gobolinux.org>2011-09-16 17:09:14 -0300
commit1dba81b8e19bd1b915d102b2071e8f8fd58fb5c6 (patch)
treecf07fcb62038d6431fde14e18881d349bff6c301
parent18f764d9f567fb4066d2e7af301de599f787a53e (diff)
downloadluarocks-1dba81b8e19bd1b915d102b2071e8f8fd58fb5c6.tar.gz
luarocks-1dba81b8e19bd1b915d102b2071e8f8fd58fb5c6.tar.bz2
luarocks-1dba81b8e19bd1b915d102b2071e8f8fd58fb5c6.zip
Replace rocks_trees and rocks_servers with the one in the home file; do not merge as that would be confusing.
Also, be extra careful in deep_merge; do not assume tables are so nicely formed.
-rw-r--r--src/luarocks/cfg.lua6
-rw-r--r--src/luarocks/util.lua6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 476bfbc3..7e4093a6 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -112,6 +112,12 @@ if not site_config.LUAROCKS_FORCE_CONFIG then
112 local home_overrides = persist.load_into_table(home_config_file, { home = home }) 112 local home_overrides = persist.load_into_table(home_config_file, { home = home })
113 if home_overrides then 113 if home_overrides then
114 local util = require("luarocks.util") 114 local util = require("luarocks.util")
115 if home_overrides.rocks_trees then
116 _M.rocks_trees = nil
117 end
118 if home_overrides.rocks_servers then
119 _M.rocks_servers = nil
120 end
115 util.deep_merge(_M, home_overrides) 121 util.deep_merge(_M, home_overrides)
116 end 122 end
117end 123end
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 562953d9..24c2accb 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -84,7 +84,11 @@ function deep_merge(dst, src)
84 if not dst[k] then 84 if not dst[k] then
85 dst[k] = {} 85 dst[k] = {}
86 end 86 end
87 deep_merge(dst[k], v) 87 if type(dst[k]) == "table" then
88 deep_merge(dst[k], v)
89 else
90 dst[k] = v
91 end
88 else 92 else
89 dst[k] = v 93 dst[k] = v
90 end 94 end