Repository: iterative/dvc

Issue:
get: directory is checked-out inside pwd instead of it's own directory
## Bug Report

```console
$ cd "$(mktemp -d)"
$ dvc get https://github.com/schacon/cowsay
$ ls
beavis.zen.cow  daemon.cow             eyes.cow           kitty.cow       milk.cow       sheep.cow        stimpy.cow       turtle.cow
bong.cow        default.cow            flaming-sheep.cow  koala.cow       moofasa.cow    skeleton.cow     supermilker.cow  tux.cow
bud-frogs.cow   dragon-and-cow.cow     ghostbusters.cow   kosh.cow        moose.cow      small.cow        surgery.cow      udder.cow
bunny.cow       dragon.cow             head-in.cow        luke-koala.cow  mutilated.cow  sodomized.cow    telebears.cow    vader.cow
cheese.cow      elephant.cow           hellokitty.cow     mech-and-cow    ren.cow        squirrel.cow     three-eyes.cow   vader-koala.cow
cower.cow       elephant-in-snake.cow  kiss.cow           meow.cow        satanic.cow    stegosaurus.cow  turkey.cow       www.cow
$ rm -rf *cow
$ git checkout 0.94.0
$ dvc get https://github.com/schacon/cowsay
$ ls
cows
```
`git bisect` points me to #3883, so the regression is after `v1.0.0a7`.


Discussion:

Patch:
diff --git a/dvc/repo/tree.py b/dvc/repo/tree.py
index b1fb1192c..7b6dd29a3 100644
--- a/dvc/repo/tree.py
+++ b/dvc/repo/tree.py
@@ -404,10 +404,8 @@ class RepoTree(BaseTree):
 
         for root, _, files in self.walk(top):
             root = PathInfo(root)
-            dest_dir = root.relative_to(top)
-            makedirs(dest_dir, exist_ok=True)
+            makedirs(dest, exist_ok=True)
             for fname in files:
                 src = root / fname
-                dest = dest_dir / fname
                 with self.open(src, mode="rb") as fobj:
-                    copy_fobj_to_file(fobj, dest)
+                    copy_fobj_to_file(fobj, dest / fname)
diff --git a/scripts/schema/dvc-yaml.json b/scripts/schema/dvc-yaml.json
new file mode 100644
index 000000000..fa3ff0e73
--- /dev/null
+++ b/scripts/schema/dvc-yaml.json
@@ -0,0 +1,227 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "$comment": "v0.1.0",
+  "title": "Pipeline Schema",
+  "description": "A dvc.yaml pipeline definition",
+  "type": "object",
+  "definitions": {
+    "OutputFlags": {
+      "type": "object",
+      "description": "Output file with more flags",
+      "properties": {
+        "cache": {
+          "description": "Cache outputs by dvc",
+          "type": "boolean",
+          "default": true
+        },
+        "persist": {
+          "description": "Persist outputs among runs",
+          "type": "boolean",
+          "default": false
+        }
+      }
+    },
+    "PlotFlags": {
+      "description": "Plots file with more flags",
+      "allOf": [
+        {
+          "$ref": "#/definitions/OutputFlags"
+        }
+      ],
+      "$comment": "Unfortunately, 'additionalProperties' only works props in immediate schema.",
+      "properties": {
+        "cache": {},
+        "persist": {},
+        "x": {
+          "description": "Default field name to use as x-axis data",
+          "type": [
+            "string",
+            "integer"
+          ]
+        },
+        "y": {
+          "description": "Default field name to use as y-axis data",
+          "type": [
+            "string",
+            "integer"
+          ]
+        },
+        "x_label": {
+          "description": "Default label for the x-axis",
+          "type": "string"
+        },
+        "y_label": {
+          "description": "Default label for the y-axis",
+          "type": "string"
+        },
+        "template": {
+          "description": "Default plot template",
+          "type": "string"
+        },
+        "title": {
+          "description": "Default plot title",
+          "type": "string"
+        },
+        "header": {
+          "description": "The target CSV or TSV has a header",
+          "type": "boolean",
+          "default": false
+        }
+      },
+      "additionalProperties": false
+    },
+    "Output": {
+      "description": "An output of the stage",
+      "anyOf": [
+        {
+          "type": "string",
+          "description": "Output will be cached by dvc"
+        },
+        {
+          "type": "object",
+          "description": "Output file",
+          "patternProperties": {
+            "^.*$": {
+              "$ref": "#/definitions/OutputFlags",
+              "additionalProperties": false
+            }
+          },
+          "additionalProperties": false,
+          "maxProperties": 1
+        }
+      ]
+    }
+  },
+  "properties": {
+    "stages": {
+      "description": "List of stages.",
+      "type": "object",
+      "patternProperties": {
+        "^[A-Za-z0-9_-]+$": {
+          "description": "The stage",
+          "type": "object",
+          "properties": {
+            "cmd": {
+              "type": "string",
+              "description": "Command to run"
+            },
+            "wdir": {
+              "type": "string",
+              "description": "Working directory"
+            },
+            "deps": {
+              "type": "array",
+              "description": "Dependencies for the stage",
+              "items": {
+                "type": "string",
+                "description": "A dependency for the stage"
+              },
+              "minItems": 1,
+              "uniqueItems": true
+            },
+            "params": {
+              "type": "array",
+              "description": "Params for the stage",
+              "items": {
+                "anyOf": [
+                  {
+                    "type": "string",
+                    "description": "Params from default params file"
+                  },
+                  {
+                    "type": "object",
+                    "description": "Params from custom params file",
+                    "patternProperties": {
+                      "^.*$": {
+                        "type": "array",
+                        "description": "Custom params file",
+                        "items": {
+                          "type": "string",
+                          "description": "Params from custom file"
+                        },
+                        "minItems": 1,
+                        "uniqueItems": true
+                      }
+                    },
+                    "additionalProperties": false,
+                    "maxProperties": 1
+                  }
+                ]
+              },
+              "minItems": 1,
+              "uniqueItems": true
+            },
+            "outs": {
+              "type": "array",
+              "description": "Outputs of the stage",
+              "items": {
+                "$ref": "#/definitions/Output"
+              },
+              "minItems": 1,
+              "uniqueItems": true
+            },
+            "metrics": {
+              "type": "array",
+              "description": "Metrics outputs of the stage",
+              "items": {
+                "$ref": "#/definitions/Output"
+              },
+              "minItems": 1,
+              "uniqueItems": true
+            },
+            "plots": {
+              "type": "array",
+              "description": "Plots outputs of the stage",
+              "items": {
+                "anyOf": [
+                  {
+                    "type": "string",
+                    "description": "Plots will be cached by dvc"
+                  },
+                  {
+                    "type": "object",
+                    "description": "Output file",
+                    "patternProperties": {
+                      "^.*$": {
+                        "$ref": "#/definitions/PlotFlags"
+                      }
+                    },
+                    "maxProperties": 1
+                  }
+                ]
+              },
+              "minItems": 1,
+              "uniqueItems": true
+            },
+            "frozen": {
+              "type": "boolean",
+              "description": "Assume stage as unchanged",
+              "default": false
+            },
+            "locked": {
+              "type": "boolean",
+              "description": "Assume stage as unchanged (deprecated)",
+              "default": false
+            },
+            "always_changed": {
+              "type": "boolean",
+              "description": "Assume stage as always changed.",
+              "default": false
+            },
+            "meta": {
+              "description": "Additional information/metadata"
+            }
+          },
+          "additionalProperties": false,
+          "required": [
+            "cmd"
+          ]
+        }
+      },
+      "additionalProperties": false
+    }
+  },
+  "required": [
+    "stages"
+  ]
+}


Test patch:
diff --git a/tests/func/test_get.py b/tests/func/test_get.py
index 232a0d6ab..20ff9f9d6 100644
--- a/tests/func/test_get.py
+++ b/tests/func/test_get.py
@@ -33,7 +33,9 @@ def test_get_repo_dir(tmp_dir, erepo_dir):
     trees_equal(erepo_dir / "dir", "dir_imported")
 
 
-def test_get_git_file(tmp_dir, erepo_dir):
+@pytest.mark.parametrize("repo_type", ["git_dir", "erepo_dir"])
+def test_get_git_file(request, tmp_dir, repo_type):
+    erepo_dir = request.getfixturevalue(repo_type)
     src = "some_file"
     dst = "some_file_imported"
 
@@ -45,7 +47,9 @@ def test_get_git_file(tmp_dir, erepo_dir):
     assert (tmp_dir / dst).read_text() == "hello"
 
 
-def test_get_git_dir(tmp_dir, erepo_dir):
+@pytest.mark.parametrize("repo_type", ["git_dir", "erepo_dir"])
+def test_get_git_dir(request, tmp_dir, repo_type):
+    erepo_dir = request.getfixturevalue(repo_type)
     src = "some_directory"
     dst = "some_directory_imported"