From 1dba81b8e19bd1b915d102b2071e8f8fd58fb5c6 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 16 Sep 2011 17:09:14 -0300 Subject: 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. --- src/luarocks/cfg.lua | 6 ++++++ src/luarocks/util.lua | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 local home_overrides = persist.load_into_table(home_config_file, { home = home }) if home_overrides then local util = require("luarocks.util") + if home_overrides.rocks_trees then + _M.rocks_trees = nil + end + if home_overrides.rocks_servers then + _M.rocks_servers = nil + end util.deep_merge(_M, home_overrides) end end 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) if not dst[k] then dst[k] = {} end - deep_merge(dst[k], v) + if type(dst[k]) == "table" then + deep_merge(dst[k], v) + else + dst[k] = v + end else dst[k] = v end -- cgit v1.2.3-55-g6feb