# # # patch "cmd_netsync.cc" # from [1375806d314e6e1b9d8c0659aaba1b47acf7b8d2] # to [a45569ce4b7735f449ed9b05e3e12ac7c0457c97] # # patch "tests/clone_branch_no_dir/__driver__.lua" # from [79f7583ce446afedfea0330cf7b9ea059f17b2ea] # to [33437917b4efdadb0d8fcf8c43de26b4fa4f5b3d] # ============================================================ --- cmd_netsync.cc 1375806d314e6e1b9d8c0659aaba1b47acf7b8d2 +++ cmd_netsync.cc a45569ce4b7735f449ed9b05e3e12ac7c0457c97 @@ -366,6 +366,7 @@ CMD(clone, "clone", "", CMD_REF(network) E(!branchname().empty(), origin::user, F("you must specify a branch to clone")); + bool target_is_current_dir = false; if (args.size() == 2) { // No checkout dir specified, use branch name for dir. @@ -375,10 +376,17 @@ CMD(clone, "clone", "", CMD_REF(network) { // Checkout to specified dir. workspace_dir = system_path(idx(args, 2)); + if (idx(args, 2) == utf8(".")) + target_is_current_dir = true; } - require_path_is_nonexistent - (workspace_dir, F("clone destination directory '%s' already exists") % workspace_dir); + if (!target_is_current_dir) + { + require_path_is_nonexistent + (workspace_dir, + F("clone destination directory '%s' already exists") + % workspace_dir); + } // remember the initial working dir so that relative file:// // db URIs will work @@ -386,7 +394,9 @@ CMD(clone, "clone", "", CMD_REF(network) bool internal_db = !app.opts.dbname_given || app.opts.dbname.empty(); - dir_cleanup_helper remove_on_fail(workspace_dir, internal_db); + system_path _MTN_dir = workspace_dir / path_component("_MTN"); + dir_cleanup_helper remove_on_fail(target_is_current_dir ? _MTN_dir : workspace_dir, + internal_db); // paths.cc's idea of the current workspace root is wrong at this point if (internal_db) ============================================================ --- tests/clone_branch_no_dir/__driver__.lua 79f7583ce446afedfea0330cf7b9ea059f17b2ea +++ tests/clone_branch_no_dir/__driver__.lua 33437917b4efdadb0d8fcf8c43de26b4fa4f5b3d @@ -17,6 +17,6 @@ check(nodb_mtn("clone", testURI, "mybran -- but succeed if given a specific dir check(nodb_mtn("clone", testURI, "mybranch", "otherdir"), 0, false, false) --- clone into . should also fail, unlike checkout +-- clone into . should not fail, like checkout mkdir("test4") -check(indir("test4", nodb_mtn("clone", testURI, "mybranch", ".")), 1, false, false) +check(indir("test4", nodb_mtn("clone", testURI, "mybranch", ".")), 0, false, false)