Commit ff7a1fb9 authored by enne@chromium.org's avatar enne@chromium.org

Let git cl format be runnable outside of the root

This will also enable git cl format to be more easily runnable by
presubmit within a subdirectory.

BUG=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@239821 0039d316-1c4b-4281-b951-d872f2087c98
parent 152cca5e
......@@ -2248,6 +2248,12 @@ def CMDformat(parser, args):
if args:
parser.error('Unrecognized args: %s' % ' '.join(args))
# git diff generates paths against the root of the repository. Change
# to that directory so clang-format can find files even within subdirs.
rel_base_path = RunGit(['rev-parse', '--show-cdup']).strip()
if rel_base_path:
os.chdir(rel_base_path)
# Generate diff for the current branch's changes.
diff_cmd = ['diff', '--no-ext-diff', '--no-prefix']
if opts.full:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment