summaryrefslogtreecommitdiff
path: root/lib/gall/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gall/util.lua')
-rw-r--r--lib/gall/util.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/gall/util.lua b/lib/gall/util.lua
new file mode 100644
index 0000000..d6c5297
--- /dev/null
+++ b/lib/gall/util.lua
@@ -0,0 +1,29 @@
+-- gall.ll
+--
+-- Git Abstraction Layer for Lua -- Utility functions
+--
+-- Copyright 2012 Daniel Silverstone <dsilvers@digital-scurf.org>
+--
+--
+
+local function deep_copy(t, memo)
+ if not memo then memo = {} end
+ if memo[t] then return memo[t] end
+ local ret = {}
+ local kk, vv
+ for k, v in pairs(t) do
+ kk, vv = k, v
+ if type(k) == "table" then
+ kk = _deep_copy(k)
+ end
+ if type(v) == "table" then
+ vv = _deep_copy(v)
+ end
+ ret[kk] = vv
+ end
+ return ret
+end
+
+return {
+ deep_copy = deep_copy,
+}