diff --git a/lib/clone.js b/lib/clone.js index b1388b589..8efdae739 100644 --- a/lib/clone.js +++ b/lib/clone.js @@ -1,4 +1,5 @@ var NodeGit = require("../"); +var shallowClone = require("./utils/shallow_clone"); var normalizeOptions = NodeGit.Utils.normalizeOptions; var Clone = NodeGit.Clone; @@ -17,6 +18,7 @@ Clone.clone = function(url, local_path, options) { var remoteCallbacks; if (options) { + options = shallowClone(options); remoteCallbacks = options.remoteCallbacks; delete options.remoteCallbacks; } diff --git a/lib/utils/shallow_clone.js b/lib/utils/shallow_clone.js new file mode 100644 index 000000000..f93e67523 --- /dev/null +++ b/lib/utils/shallow_clone.js @@ -0,0 +1,10 @@ +module.exports = function(obj) { + var merges = Array.prototype.slice.call(arguments, 1); + + return merges.reduce(function(obj, merge) { + return Object.keys(merge).reduce(function(obj, key) { + obj[key] = merge[key]; + return obj; + }, obj); + }, obj || {}); +};