Error out in `gclient config` if --name is relative

This helps prevent behavior such as setting '--name .' so that the .gclient
file contains '.' as the name of the solution, and the .gclient file ends
up a sibling of the .git file, rather than a sibling of the git checkout's
containing directory.

R=iannucci@chromium.org, thestig@chromium.org

Review URL: https://codereview.chromium.org/1406053003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297343 0039d316-1c4b-4281-b951-d872f2087c98
changes/01/332501/1
agable@chromium.org 10 years ago
parent 7c4b703a05
commit f2214673e1

@ -1886,6 +1886,12 @@ def CMDconfig(parser, args):
else:
# specify an alternate relpath for the given URL.
name = options.name
if not os.path.abspath(os.path.join(os.getcwd(), name)).startswith(
os.getcwd()):
parser.error('Do not pass a relative path for --name.')
if any(x in ('..', '.', '/', '\\') for x in name.split(os.sep)):
parser.error('Do not include relative path components in --name.')
deps_file = options.deps_file
safesync_url = ''
if len(args) > 1:

Loading…
Cancel
Save