Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Unified Diff: git_cl.py

Issue 22308002: allow running "git cl format" from subdirectories (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 64ebcd9e42a7a1bc89231caa6dc2cf342438296b..156d28a6e9b53c3e08221e269b72eab417191563 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2121,13 +2121,16 @@ def CMDformat(parser, args):
diff_cmd += ['*' + ext for ext in CLANG_EXTS]
diff_output = RunGit(diff_cmd)
+ top_dir = RunGit(["rev-parse", "--show-toplevel"]).rstrip('\n')
+
if opts.full:
# diff_output is a list of files to send to clang-format.
files = diff_output.splitlines()
if not files:
print "Nothing to format."
return 0
- RunCommand(['clang-format', '-i', '-style', 'Chromium'] + files)
+ RunCommand(['clang-format', '-i', '-style', 'Chromium'] + files,
+ cwd=top_dir)
else:
# diff_output is a patch to send to clang-format-diff.py
cfd_path = os.path.join('/usr', 'lib', 'clang-format',
@@ -2135,7 +2138,7 @@ def CMDformat(parser, args):
if not os.path.exists(cfd_path):
DieWithError('Could not find clang-format-diff at %s.' % cfd_path)
cmd = [sys.executable, cfd_path, '-style', 'Chromium']
- RunCommand(cmd, stdin=diff_output)
+ RunCommand(cmd, stdin=diff_output, cwd=top_dir)
return 0
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698