Skip to content

Commit 9f279b3

Browse files
forbid absolute paths for plain git repositories
1 parent 0e2ef47 commit 9f279b3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dvc/repo/get.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def __init__(self):
2727
)
2828

2929

30+
def _forbid_absolute_path(path):
31+
if os.path.isabs(path):
32+
raise FileNotFoundError
33+
34+
3035
@staticmethod
3136
def get(url, path, out=None, rev=None):
3237
out = resolve_output(path, out)
@@ -66,8 +71,7 @@ def get(url, path, out=None, rev=None):
6671
return
6772

6873
# Either an uncached out with absolute path or a user error
69-
if os.path.isabs(path):
70-
raise FileNotFoundError
74+
_forbid_absolute_path(path)
7175

7276
fs_copy(os.path.join(repo.root_dir, path), out)
7377
return
@@ -76,6 +80,7 @@ def get(url, path, out=None, rev=None):
7680
# Not a DVC repository, continue below and copy from git
7781
pass
7882

83+
_forbid_absolute_path(path)
7984
raw_git_dir = cached_clone(url, rev=rev)
8085
fs_copy(os.path.join(raw_git_dir, path), out)
8186
except (OutputNotFoundError, FileNotFoundError):

0 commit comments

Comments
 (0)